mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
simplify debug option
This commit is contained in:
35
jc/cli.py
35
jc/cli.py
@ -387,32 +387,25 @@ def main():
|
|||||||
|
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
if debug:
|
for arg in sys.argv:
|
||||||
if verbose_debug:
|
parser_name = parser_shortname(arg)
|
||||||
import cgitb
|
|
||||||
cgitb.enable(display=1, logdir=None, context=5, format="text")
|
|
||||||
|
|
||||||
for arg in sys.argv:
|
if parser_name in parsers:
|
||||||
parser_name = parser_shortname(arg)
|
# load parser module just in time so we don't need to load all modules
|
||||||
|
parser = parser_module(arg)
|
||||||
if parser_name in parsers:
|
try:
|
||||||
# load parser module just in time so we don't need to load all modules
|
|
||||||
parser = parser_module(arg)
|
|
||||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
result = parser.parse(data, raw=raw, quiet=quiet)
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
for arg in sys.argv:
|
|
||||||
parser_name = parser_shortname(arg)
|
|
||||||
|
|
||||||
if parser_name in parsers:
|
except Exception:
|
||||||
# load parser module just in time so we don't need to load all modules
|
if verbose_debug:
|
||||||
parser = parser_module(arg)
|
import cgitb
|
||||||
try:
|
cgitb.enable(display=1, logdir=None, context=5, format="text")
|
||||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
|
||||||
found = True
|
if debug:
|
||||||
break
|
raise
|
||||||
except Exception:
|
else:
|
||||||
jc.utils.error_message(
|
jc.utils.error_message(
|
||||||
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
|
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Reference in New Issue
Block a user