diff --git a/src/stratis_cli/_main.py b/src/stratis_cli/_main.py index a0b16a79d..7002ca1db 100644 --- a/src/stratis_cli/_main.py +++ b/src/stratis_cli/_main.py @@ -23,15 +23,13 @@ from ._error_reporting import handle_error from ._errors import StratisCliActionError, StratisCliEnvironmentError -from ._parser import gen_parser +from ._parser import PARSER def run() -> Callable: """ Generate a function that parses arguments and executes. """ - parser = gen_parser() - # Set default configuration parameters for display of sizes, i.e., values # that are generally given in bytes or some multiple thereof. jb.Config.set_display_config(jb.DisplayConfig(show_approx_str=False)) @@ -40,11 +38,11 @@ def the_func(command_line_args): """ Run according to the arguments passed. """ - namespace = parser.parse_args(command_line_args) + namespace = PARSER.parse_args(command_line_args) post_parser = getattr(namespace, "post_parser", None) if post_parser is not None: - post_parser(namespace).verify(namespace, parser) + post_parser(namespace).verify(namespace, PARSER) try: try: diff --git a/src/stratis_cli/_parser/__init__.py b/src/stratis_cli/_parser/__init__.py index 7b951c3fb..a1d27a28c 100644 --- a/src/stratis_cli/_parser/__init__.py +++ b/src/stratis_cli/_parser/__init__.py @@ -14,4 +14,4 @@ """ Top level of CLI. """ -from ._parser import gen_parser +from ._parser import PARSER diff --git a/src/stratis_cli/_parser/_parser.py b/src/stratis_cli/_parser/_parser.py index 51aaa2be5..a4f11e537 100644 --- a/src/stratis_cli/_parser/_parser.py +++ b/src/stratis_cli/_parser/_parser.py @@ -273,3 +273,6 @@ def gen_parser(): parser.set_defaults(func=print_help(parser)) return parser + + +PARSER = gen_parser()