aboutsummaryrefslogtreecommitdiffstats
path: root/src/argparser.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-08-18 13:05:32 +0200
committerMattias Andrée <maandree@operamail.com>2013-08-18 13:05:32 +0200
commitf8a5ac5337702119cb0f285879953cbdeceaeb20 (patch)
tree9e3d868dac98450e90ca8afd689424f26de603dd /src/argparser.py
parentforgot to update the version (diff)
downloadargparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.gz
argparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.bz2
argparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.xz
add alternative mode
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/argparser.py')
-rw-r--r--src/argparser.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/argparser.py b/src/argparser.py
index d9f9d55..93b0287 100644
--- a/src/argparser.py
+++ b/src/argparser.py
@@ -176,12 +176,13 @@ class ArgParser():
self.optmap[alt] = (stdalt, ArgParser.VARIADIC)
- def parse(self, argv = sys.argv):
+ def parse(self, argv = sys.argv, alternative = False):
'''
Parse arguments
- @param args:list<str> The command line arguments, should include the execute file at index 0, `sys.argv` is default
- @return :bool Whether no unrecognised option is used
+ @param args:list<str> The command line arguments, should include the execute file at index 0, `sys.argv` is default
+ @param alternative:bool Use single dash/plus for long options
+ @return :bool Whether no unrecognised option is used
'''
self.argcount = len(argv) - 1
self.arguments = argv[1:]
@@ -220,7 +221,7 @@ class ArgParser():
elif arg == '++': tmpdashed = True
elif arg == '--': dashed = True
elif (len(arg) > 1) and (arg[0] in ('-', '+')):
- if (len(arg) > 2) and (arg[:2] in ('--', '++')):
+ if alternative or ((len(arg) > 2) and (arg[:2] in ('--', '++'))):
if dontget > 0:
dontget -= 1
elif (arg in self.optmap) and (self.optmap[arg][1] == ArgParser.ARGUMENTLESS):