mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
refactor helptext() function
This commit is contained in:
13
jc/jc.py
13
jc/jc.py
@ -34,8 +34,9 @@ def ctrlc(signum, frame):
|
|||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def helptext(message):
|
||||||
helptext = '''
|
helptext_string = f'''
|
||||||
|
jc: {message}
|
||||||
|
|
||||||
Usage: jc PARSER [OPTIONS]
|
Usage: jc PARSER [OPTIONS]
|
||||||
|
|
||||||
@ -70,10 +71,14 @@ def main():
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
print(textwrap.dedent(helptext_string), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
signal.signal(signal.SIGINT, ctrlc)
|
signal.signal(signal.SIGINT, ctrlc)
|
||||||
|
|
||||||
if sys.stdin.isatty():
|
if sys.stdin.isatty():
|
||||||
print('jc: missing piped data' + textwrap.dedent(helptext), file=sys.stderr)
|
helptext('missing piped data')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
data = sys.stdin.read()
|
data = sys.stdin.read()
|
||||||
@ -149,7 +154,7 @@ def main():
|
|||||||
result = jc.parsers.w.parse(data, raw=raw)
|
result = jc.parsers.w.parse(data, raw=raw)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('jc: missing or incorrect arguments' + textwrap.dedent(helptext), file=sys.stderr)
|
helptext('missing or incorrect arguments')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
# output resulting dictionary as json
|
# output resulting dictionary as json
|
||||||
|
Reference in New Issue
Block a user