mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-17 01:32:37 +02:00
reorganize main function. remove pass condition.
This commit is contained in:
18
jc/cli.py
18
jc/cli.py
@ -561,19 +561,13 @@ def main():
|
|||||||
jc.utils.error_message(f'"{run_command_str}" command could not be run. For details use the -d or -dd option.')
|
jc.utils.error_message(f'"{run_command_str}" command could not be run. For details use the -d or -dd option.')
|
||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
|
||||||
elif run_command is None:
|
# elif run_command is None:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
else:
|
elif run_command is not None:
|
||||||
jc.utils.error_message(f'parser not found for "{run_command_str}". Use "jc -h" for help.')
|
jc.utils.error_message(f'parser not found for "{run_command_str}". Use "jc -h" for help.')
|
||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
|
||||||
if sys.stdin.isatty() and magic_stdout is None:
|
|
||||||
jc.utils.error_message('Missing piped data. Use "jc -h" for help.')
|
|
||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
|
||||||
|
|
||||||
data = magic_stdout or sys.stdin.read()
|
|
||||||
|
|
||||||
# find the correct parser
|
# find the correct parser
|
||||||
if magic_found_parser:
|
if magic_found_parser:
|
||||||
parser = parser_module(magic_found_parser)
|
parser = parser_module(magic_found_parser)
|
||||||
@ -595,6 +589,12 @@ def main():
|
|||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
|
||||||
# parse the data
|
# parse the data
|
||||||
|
if sys.stdin.isatty() and magic_stdout is None:
|
||||||
|
jc.utils.error_message('Missing piped data. Use "jc -h" for help.')
|
||||||
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
|
||||||
|
data = magic_stdout or sys.stdin.read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
result = parser.parse(data, raw=raw, quiet=quiet)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user