1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

correct parser search in magic()

This commit is contained in:
Kelly Brazil
2020-02-13 17:48:21 -08:00
parent 18fb69e36e
commit cfba62db20

View File

@ -206,14 +206,21 @@ def magic():
# find the command and parser
for parser in parser_info:
if 'magic_commands' in parser:
# first pass for two word commands: e.g. 'pip list'
for magic_command in parser['magic_commands']:
try:
# two arguments: e.g. 'pip list'
if ' '.join(args_given[0:2]) == magic_command:
found_parser = parser['argument']
break
# one argument: e.g. 'ls'
elif args_given[0] == magic_command:
# No command found - use standard syntax (for cases like 'jc -a')
except Exception:
break
# second pass for one word commands: e.g. 'ls'
if not found_parser:
for magic_command in parser['magic_commands']:
try:
if args_given[0] == magic_command:
found_parser = parser['argument']
break
# No command found - use standard syntax (for cases like 'jc -a')