mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-17 01:32:37 +02:00
cleanup
This commit is contained in:
24
jc/cli.py
24
jc/cli.py
@ -314,7 +314,6 @@ class JcCli():
|
|||||||
y_string = y_string_buf.getvalue().decode('utf-8')[:-1]
|
y_string = y_string_buf.getvalue().decode('utf-8')[:-1]
|
||||||
|
|
||||||
if not self.mono:
|
if not self.mono:
|
||||||
# set colors
|
|
||||||
class JcStyle(Style):
|
class JcStyle(Style):
|
||||||
styles = self.custom_colors
|
styles = self.custom_colors
|
||||||
|
|
||||||
@ -344,7 +343,6 @@ class JcCli():
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not self.mono:
|
if not self.mono:
|
||||||
# set colors
|
|
||||||
class JcStyle(Style):
|
class JcStyle(Style):
|
||||||
styles = self.custom_colors
|
styles = self.custom_colors
|
||||||
|
|
||||||
@ -408,6 +406,7 @@ class JcCli():
|
|||||||
|
|
||||||
# all options popped and no command found - for case like 'jc -x'
|
# all options popped and no command found - for case like 'jc -x'
|
||||||
if len(args_given) == 0:
|
if len(args_given) == 0:
|
||||||
|
self.magic_options = []
|
||||||
return
|
return
|
||||||
|
|
||||||
# create a dictionary of magic_commands to their respective parsers.
|
# create a dictionary of magic_commands to their respective parsers.
|
||||||
@ -632,8 +631,8 @@ class JcCli():
|
|||||||
self.compute_exit_code_and_quit()
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
def ctrlc(self, signum, frame):
|
def ctrlc(self, signum, frame):
|
||||||
"""Exit with error on SIGINT"""
|
"""Exit on SIGINT"""
|
||||||
sys.exit(self.JC_ERROR_EXIT)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# break on ctrl-c keyboard interrupt
|
# break on ctrl-c keyboard interrupt
|
||||||
@ -665,8 +664,6 @@ class JcCli():
|
|||||||
if opt.startswith('-') and not opt.startswith('--'):
|
if opt.startswith('-') and not opt.startswith('--'):
|
||||||
self.options.extend(opt[1:])
|
self.options.extend(opt[1:])
|
||||||
|
|
||||||
self.env_colors = os.getenv('JC_COLORS')
|
|
||||||
|
|
||||||
self.about = 'a' in self.options
|
self.about = 'a' in self.options
|
||||||
self.debug = 'd' in self.options
|
self.debug = 'd' in self.options
|
||||||
self.verbose_debug = self.options.count('d') > 1
|
self.verbose_debug = self.options.count('d') > 1
|
||||||
@ -685,6 +682,7 @@ class JcCli():
|
|||||||
self.zsh_comp = 'Z' in self.options
|
self.zsh_comp = 'Z' in self.options
|
||||||
|
|
||||||
self.set_mono()
|
self.set_mono()
|
||||||
|
self.env_colors = os.getenv('JC_COLORS')
|
||||||
self.set_custom_colors()
|
self.set_custom_colors()
|
||||||
|
|
||||||
if self.verbose_debug:
|
if self.verbose_debug:
|
||||||
@ -693,28 +691,28 @@ class JcCli():
|
|||||||
if self.about:
|
if self.about:
|
||||||
self.data_out = self.about_jc()
|
self.data_out = self.about_jc()
|
||||||
self.safe_print_out()
|
self.safe_print_out()
|
||||||
sys.exit(0)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
if self.help_me:
|
if self.help_me:
|
||||||
self.help_doc()
|
self.help_doc()
|
||||||
sys.exit(0)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
if self.version_info:
|
if self.version_info:
|
||||||
utils._safe_print(self.versiontext())
|
utils._safe_print(self.versiontext())
|
||||||
sys.exit(0)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
if self.bash_comp:
|
if self.bash_comp:
|
||||||
utils._safe_print(bash_completion())
|
utils._safe_print(bash_completion())
|
||||||
sys.exit(0)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
if self.zsh_comp:
|
if self.zsh_comp:
|
||||||
utils._safe_print(zsh_completion())
|
utils._safe_print(zsh_completion())
|
||||||
sys.exit(0)
|
self.compute_exit_code_and_quit()
|
||||||
|
|
||||||
# if magic syntax used, try to run the command and error if it's not found, etc.
|
# if magic syntax used, try to run the command and set the magic attributes
|
||||||
self.do_magic()
|
self.do_magic()
|
||||||
|
|
||||||
# find the correct parser
|
# find the correct parser from magic_parser or user-supplied
|
||||||
self.find_parser()
|
self.find_parser()
|
||||||
|
|
||||||
# parse and print to stdout
|
# parse and print to stdout
|
||||||
|
Reference in New Issue
Block a user