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

clean up about code

This commit is contained in:
Kelly Brazil
2019-12-16 08:18:37 -08:00
parent 75eff3adea
commit 0ffaaa6e73

View File

@ -149,7 +149,6 @@ def json_out(data, pretty=False):
def main(): def main():
signal.signal(signal.SIGINT, ctrlc) signal.signal(signal.SIGINT, ctrlc)
about = False
debug = False debug = False
pretty = False pretty = False
quiet = False quiet = False
@ -169,25 +168,24 @@ def main():
raw = True raw = True
if '-a' in sys.argv: if '-a' in sys.argv:
about = True json_out(about_jc(), pretty=pretty)
result = about_jc() exit()
if sys.stdin.isatty() and not about: if sys.stdin.isatty():
helptext('missing piped data') helptext('missing piped data')
exit() exit()
if not about:
data = sys.stdin.read() data = sys.stdin.read()
found = False found = False
if debug and not about: if debug:
for arg in sys.argv: for arg in sys.argv:
if arg in parser_map: if arg in parser_map:
result = parser_map[arg].parse(data, raw=raw, quiet=quiet) result = parser_map[arg].parse(data, raw=raw, quiet=quiet)
found = True found = True
break break
elif not about: else:
for arg in sys.argv: for arg in sys.argv:
if arg in parser_map: if arg in parser_map:
try: try:
@ -199,7 +197,7 @@ def main():
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.') 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.')
exit(1) exit(1)
if not found and not about: if not found:
helptext('missing or incorrect arguments') helptext('missing or incorrect arguments')
exit() exit()