mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
fix magic parser and tests
This commit is contained in:
@ -430,8 +430,9 @@ Examples:
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
# if -h, -a, or -v found in options, then bail out
|
# if -h, -a, or -v found in options, then clear options and bail out
|
||||||
if 'h' in self.magic_options or 'a' in self.magic_options or 'v' in self.magic_options:
|
if 'h' in self.magic_options or 'a' in self.magic_options or 'v' in self.magic_options:
|
||||||
|
self.magic_options = []
|
||||||
return
|
return
|
||||||
|
|
||||||
# all options popped and no command found - for case like 'jc -x'
|
# all options popped and no command found - for case like 'jc -x'
|
||||||
@ -538,9 +539,8 @@ Examples:
|
|||||||
self.args = sys.argv
|
self.args = sys.argv
|
||||||
self.magic_parser()
|
self.magic_parser()
|
||||||
|
|
||||||
# set magic options if magic syntax was found
|
# add magic options to regular options
|
||||||
if self.magic_found_parser:
|
self.options.extend(self.magic_options)
|
||||||
self.options.extend(self.magic_options)
|
|
||||||
|
|
||||||
# find options if magic_parser did not find a command
|
# find options if magic_parser did not find a command
|
||||||
if not self.magic_found_parser:
|
if not self.magic_found_parser:
|
||||||
|
@ -20,16 +20,16 @@ class MyTests(unittest.TestCase):
|
|||||||
'jc -p -r airport -I': ('--airport', ['p', 'r'], ['airport', '-I']),
|
'jc -p -r airport -I': ('--airport', ['p', 'r'], ['airport', '-I']),
|
||||||
'jc -prd airport -I': ('--airport', ['p', 'r', 'd'], ['airport', '-I']),
|
'jc -prd airport -I': ('--airport', ['p', 'r', 'd'], ['airport', '-I']),
|
||||||
'jc -p nonexistent command': (None, ['p'], ['nonexistent', 'command']),
|
'jc -p nonexistent command': (None, ['p'], ['nonexistent', 'command']),
|
||||||
'jc -ap': (None, ['a', 'p'], None),
|
'jc -ap': (None, [], None),
|
||||||
'jc -a arp -a': (None, ['a'], None),
|
'jc -a arp -a': (None, [], None),
|
||||||
'jc -v': (None, ['v'], None),
|
'jc -v': (None, [], None),
|
||||||
'jc -h': (None, ['h'], None),
|
'jc -h': (None, [], None),
|
||||||
'jc -h --arp': (None, ['h'], None),
|
'jc -h --arp': (None, ['h'], None),
|
||||||
'jc -h arp': (None, ['h'], None),
|
'jc -h arp': (None, [], None),
|
||||||
'jc -h arp -a': (None, ['h'], None),
|
'jc -h arp -a': (None, [], None),
|
||||||
'jc --pretty dig': ('--dig', ['p'], ['dig']),
|
'jc --pretty dig': ('--dig', ['p'], ['dig']),
|
||||||
'jc --pretty --monochrome --quiet --raw dig': ('--dig', ['p', 'm', 'q', 'r'], ['dig']),
|
'jc --pretty --monochrome --quiet --raw dig': ('--dig', ['p', 'm', 'q', 'r'], ['dig']),
|
||||||
'jc --about --yaml-out': (None, ['a', 'y'], None)
|
'jc --about --yaml-out': (None, [], None)
|
||||||
}
|
}
|
||||||
|
|
||||||
for command, expected in commands.items():
|
for command, expected in commands.items():
|
||||||
|
Reference in New Issue
Block a user