From 9747856f15edc8f964f93466b5733d1dc41a49c5 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Mon, 1 May 2023 16:23:17 -0400 Subject: [PATCH] [O] Split create_parser function https://github.com/hykilpikonna/hyfetch/issues/96 --- hyfetch/main.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index a1f97edb..f9bcd1eb 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -295,18 +295,7 @@ def create_config() -> Config: return c -def run(): - # Optional: Import readline - try: - import readline - except ModuleNotFoundError: - pass - - # On Windows: Try to fix color rendering if not in git bash - if IS_WINDOWS: - import colorama - colorama.just_fix_windows_console() - +def create_parser() -> argparse.ArgumentParser: # Create CLI hyfetch = color('&l&bhyfetch&~&L') parser = argparse.ArgumentParser(description=color(f'{hyfetch} - neofetch with flags <3')) @@ -330,6 +319,22 @@ def run(): # --ask-exit: Ask for input before exiting parser.add_argument('--ask-exit', action='store_true', help=argparse.SUPPRESS) + return parser + + +def run(): + # Optional: Import readline + try: + import readline + except ModuleNotFoundError: + pass + + # On Windows: Try to fix color rendering if not in git bash + if IS_WINDOWS: + import colorama + colorama.just_fix_windows_console() + + parser = create_parser() args = parser.parse_args() if args.version: