summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-12-18 22:22:27 +0100
committermathieui <mathieui@mathieui.net>2014-12-18 22:22:27 +0100
commit631f5dd42a31f90ffcf7c08557db863069e60017 (patch)
treee18fad567c86491de7024d24c0729c241f78b734 /src
parent561c46f126373ae4595f8ddbcb7412425f070b18 (diff)
downloadpoezio-631f5dd42a31f90ffcf7c08557db863069e60017.tar.gz
poezio-631f5dd42a31f90ffcf7c08557db863069e60017.tar.bz2
poezio-631f5dd42a31f90ffcf7c08557db863069e60017.tar.xz
poezio-631f5dd42a31f90ffcf7c08557db863069e60017.zip
Allow -1 as a value for optional arguments in the args parser to collect an unspecified number of items
Diffstat (limited to 'src')
-rw-r--r--src/decorators.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/decorators.py b/src/decorators.py
index 627d8f59..c4ea6563 100644
--- a/src/decorators.py
+++ b/src/decorators.py
@@ -120,7 +120,11 @@ class CommandArgParser(object):
if len(args) < mandatory:
return func(self, None, *a, **kw)
res, args = args[:mandatory], args[mandatory:]
- opt_args = args[:optional]
+ if optional == -1:
+ opt_args = args[:]
+ else:
+ opt_args = args[:optional]
+
if opt_args:
res += opt_args
args = args[len(opt_args):]