1
0
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:
Kelly Brazil
2022-10-03 13:03:42 -07:00
parent cacda0f3cc
commit 2792d05c7f
2 changed files with 11 additions and 11 deletions

View File

@ -430,8 +430,9 @@ Examples:
else:
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:
self.magic_options = []
return
# all options popped and no command found - for case like 'jc -x'
@ -538,9 +539,8 @@ Examples:
self.args = sys.argv
self.magic_parser()
# set magic options if magic syntax was found
if self.magic_found_parser:
self.options.extend(self.magic_options)
# add magic options to regular options
self.options.extend(self.magic_options)
# find options if magic_parser did not find a command
if not self.magic_found_parser:

View File

@ -20,16 +20,16 @@ class MyTests(unittest.TestCase):
'jc -p -r airport -I': ('--airport', ['p', 'r'], ['airport', '-I']),
'jc -prd airport -I': ('--airport', ['p', 'r', 'd'], ['airport', '-I']),
'jc -p nonexistent command': (None, ['p'], ['nonexistent', 'command']),
'jc -ap': (None, ['a', 'p'], None),
'jc -a arp -a': (None, ['a'], None),
'jc -v': (None, ['v'], None),
'jc -h': (None, ['h'], None),
'jc -ap': (None, [], None),
'jc -a arp -a': (None, [], None),
'jc -v': (None, [], None),
'jc -h': (None, [], None),
'jc -h --arp': (None, ['h'], None),
'jc -h arp': (None, ['h'], None),
'jc -h arp -a': (None, ['h'], None),
'jc -h arp': (None, [], None),
'jc -h arp -a': (None, [], None),
'jc --pretty dig': ('--dig', ['p'], ['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():