Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/stratis_cli/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/stratis_cli/_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""
Top level of CLI.
"""
from ._parser import gen_parser
from ._parser import PARSER
3 changes: 3 additions & 0 deletions src/stratis_cli/_parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,6 @@ def gen_parser():
parser.set_defaults(func=print_help(parser))

return parser


PARSER = gen_parser()
Loading