mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
remove cli functions from utils
This commit is contained in:
54
jc/utils.py
54
jc/utils.py
@ -3,63 +3,25 @@ import textwrap
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def ctrlc(signum, frame):
|
def warning_message(message):
|
||||||
exit()
|
error_string = f'''
|
||||||
|
jc: Warning - {message}
|
||||||
|
|
||||||
def helptext(message):
|
|
||||||
helptext_string = f'''
|
|
||||||
jc: {message}
|
|
||||||
|
|
||||||
Usage: jc PARSER [OPTIONS]
|
|
||||||
|
|
||||||
Parsers:
|
|
||||||
--arp arp parser
|
|
||||||
--df df parser
|
|
||||||
--dig dig parser
|
|
||||||
--env env parser
|
|
||||||
--free free parser
|
|
||||||
--history history parser
|
|
||||||
--ifconfig iconfig parser
|
|
||||||
--iptables iptables parser
|
|
||||||
--jobs jobs parser
|
|
||||||
--ls ls parser
|
|
||||||
--lsblk lsblk parser
|
|
||||||
--lsmod lsmod parser
|
|
||||||
--lsof lsof parser
|
|
||||||
--mount mount parser
|
|
||||||
--netstat netstat parser
|
|
||||||
--ps ps parser
|
|
||||||
--route route parser
|
|
||||||
--uname uname parser
|
|
||||||
--uptime uptime parser
|
|
||||||
--w w parser
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-p pretty print output
|
|
||||||
-q quiet - suppress warnings
|
|
||||||
-r raw JSON output
|
|
||||||
|
|
||||||
Example:
|
|
||||||
ls -al | jc --ls -p
|
|
||||||
'''
|
'''
|
||||||
|
print(textwrap.dedent(error_string), file=sys.stderr)
|
||||||
print(textwrap.dedent(helptext_string), file=sys.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def error_message(message):
|
def error_message(message):
|
||||||
error_string = f'''
|
error_string = f'''
|
||||||
jc: {message}
|
jc: Error - {message}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
print(textwrap.dedent(error_string), file=sys.stderr)
|
print(textwrap.dedent(error_string), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def compatibility(mod_name, compatible):
|
def compatibility(mod_name, compatible):
|
||||||
'''
|
"""
|
||||||
compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
'''
|
"""
|
||||||
if sys.platform not in compatible:
|
if sys.platform not in compatible:
|
||||||
mod = mod_name.split('.')[-1]
|
mod = mod_name.split('.')[-1]
|
||||||
compat_list = ', '.join(compatible)
|
compat_list = ', '.join(compatible)
|
||||||
error_message(f'Warning - {mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compat_list}')
|
warning_message(f'{mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compat_list}')
|
||||||
|
Reference in New Issue
Block a user