allow argumented options to be unargumented of at end of command line

This commit is contained in:
Mattias Andrée 2012-10-29 20:29:25 +01:00
parent 24e0af1d94
commit 41a4a0ba9e

View file

@ -1230,15 +1230,16 @@ class ArgParser():
n = len(optqueue) n = len(optqueue)
while i < n: while i < n:
opt = optqueue[i] opt = optqueue[i]
arg = argqueue[i] arg = argqueue[i] if len(argqueue) > i else None
i += 1 i += 1
opt = self.optmap[opt][0] opt = self.optmap[opt][0]
if (opt not in self.opts) or (self.opts[opt] is None): if (opt not in self.opts) or (self.opts[opt] is None):
self.opts[opt] = [] self.opts[opt] = []
if len(argqueue) >= i:
self.opts[opt].append(arg) self.opts[opt].append(arg)
for arg in self.__arguments: for arg in self.__arguments:
if (arg[0] == VARIADIC): if arg[0] == VARIADIC:
varopt = self.opts[arg[1][0]] varopt = self.opts[arg[1][0]]
if varopt is not None: if varopt is not None:
additional = ','.join(self.files).split(',') if len(self.files) > 0 else [] additional = ','.join(self.files).split(',') if len(self.files) > 0 else []