Commit 6bfbab21 authored by ∞'s avatar 💻

Replace dashall with extraargs

parent 52c1d73e
Pipeline #2184 passed with stages
in 40 seconds
......@@ -74,7 +74,7 @@ def debug(callback, *args, **kwargs):
console_script.parser.options: {GREEN}{parser.options}{RESET}
console_script.parser.dashargs: {GREEN}{parser.dashargs}{RESET}
console_script.parser.dashkwargs: {GREEN}{parser.dashkwargs}{RESET}
console_script.parser.dashall: {GREEN}{parser.dashall}{RESET}
console_script.parser.extraargs: {GREEN}{parser.extraargs}{RESET}
''').strip()
......
import inspect
class Parser:
......@@ -13,7 +14,7 @@ class Parser:
self.funckwargs = {}
self.dashargs = []
self.dashkwargs = {}
self.dashall = []
self.extraargs = []
self.options = {}
def parse(self):
......@@ -45,6 +46,14 @@ class Parser:
return False
def append(self, arg):
spec = inspect.getargspec(self.command.target)
filled = False
if not spec.varargs and len(spec.args) == len(self.funcargs):
filled = True
if filled:
self.extraargs.append(arg)
if '=' in arg:
if arg.startswith('-'):
key, value = arg.lstrip('-').split('=')
......@@ -53,7 +62,6 @@ class Parser:
self.options[option.name] = value
else:
self.dashkwargs[key] = value
self.dashall.append(arg)
else:
key, value = arg.split('=', 1)
self.funckwargs[key] = value
......@@ -66,6 +74,5 @@ class Parser:
self.options[option.name] = True
else:
self.dashargs.append(stripped)
self.dashall.append(arg)
else:
elif not filled:
self.funcargs.append(arg)
......@@ -7,4 +7,4 @@ Kwargs: {'see': 'how'}
console_script.parser.options: {}
console_script.parser.dashargs: ['it']
console_script.parser.dashkwargs: {'parses': 'me'}
console_script.parser.dashall: ['-it', '--parses=me']
console_script.parser.extraargs: []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment