mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
use jc.utils for all warning and error messages. simply error and warning formatting.
This commit is contained in:
@ -197,7 +197,7 @@ def set_env_colors(env_colors=None):
|
|||||||
|
|
||||||
# if there is an issue with the env variable, just set all colors to default and move on
|
# if there is an issue with the env variable, just set all colors to default and move on
|
||||||
if input_error:
|
if input_error:
|
||||||
print('jc: Warning: could not parse JC_COLORS environment variable\n', file=sys.stderr)
|
jc.utils.warning_message('could not parse JC_COLORS environment variable')
|
||||||
color_list = ['default', 'default', 'default', 'default']
|
color_list = ['default', 'default', 'default', 'default']
|
||||||
|
|
||||||
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
||||||
@ -477,7 +477,7 @@ def main():
|
|||||||
jc.tracebackplus.enable(context=11)
|
jc.tracebackplus.enable(context=11)
|
||||||
|
|
||||||
if sys.stdin.isatty():
|
if sys.stdin.isatty():
|
||||||
jc.utils.error_message('missing piped data')
|
jc.utils.error_message('Missing piped data. Use "jc -h" for help.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
data = sys.stdin.read()
|
data = sys.stdin.read()
|
||||||
@ -502,11 +502,11 @@ def main():
|
|||||||
import jc.utils
|
import jc.utils
|
||||||
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'
|
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n'
|
||||||
' For details use the -d or -dd option.')
|
' For details use the -d or -dd option. Use "jc -h" for help.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
jc.utils.error_message('missing or incorrect arguments')
|
jc.utils.error_message('Missing or incorrect arguments. Use "jc -h" for help.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print(json_out(result, pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
|
print(json_out(result, pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
|
||||||
|
16
jc/utils.py
16
jc/utils.py
@ -15,13 +15,11 @@ def warning_message(message):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
no return, just prints output to STDERR
|
None - just prints output to STDERR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
error_string = f'''
|
error_string = f'jc: Warning - {message}'
|
||||||
jc: Warning - {message}
|
print(error_string, file=sys.stderr)
|
||||||
'''
|
|
||||||
print(textwrap.dedent(error_string), file=sys.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def error_message(message):
|
def error_message(message):
|
||||||
@ -34,13 +32,11 @@ def error_message(message):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
no return, just prints output to STDERR
|
None - just prints output to STDERR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
error_string = f'''
|
error_string = f'jc: Error - {message}'
|
||||||
jc: Error - {message}
|
print(error_string, file=sys.stderr)
|
||||||
'''
|
|
||||||
print(textwrap.dedent(error_string), file=sys.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def compatibility(mod_name, compatible):
|
def compatibility(mod_name, compatible):
|
||||||
|
Reference in New Issue
Block a user