From 76477134988bbcb1e5c5099b6ac632653f572419 Mon Sep 17 00:00:00 2001 From: Mathew Guest Date: Sat, 16 Nov 2024 04:04:56 -0700 Subject: [PATCH] build: removing dead code --- app_skellington/app_container.py | 3 --- app_skellington/cli.py | 24 ++++++++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app_skellington/app_container.py b/app_skellington/app_container.py index 9911d85..772d59e 100644 --- a/app_skellington/app_container.py +++ b/app_skellington/app_container.py @@ -180,9 +180,6 @@ class ApplicationContainer: except NoCommandSpecified: print("Failure: No command specified.") - def interactive_shell(self): - pass - def invoke_from_cli(self): self.invoke_command() diff --git a/app_skellington/cli.py b/app_skellington/cli.py index 4f8e901..30d7b1d 100644 --- a/app_skellington/cli.py +++ b/app_skellington/cli.py @@ -3,7 +3,7 @@ import inspect import re import sys -from . import app_container +from . import NoCommandSpecified, app_container from ._bootstrap import _bootstrap_logger # If explicit fail is enabled, any command with at least one unknown @@ -41,12 +41,12 @@ class CommandTree: ./scriptname --option="value" [submenu] [command] - is different than + is different from ./scriptname [submenu] [command] --option="value" in that option is being applied to the application in the first example and - applied to the refresh_datasets command (under the nhsn command group) in + applied to the command (under the submenu command group) in the second. In the same way the -h, --help options print different docs depending on where the help option was passed. """ @@ -82,17 +82,7 @@ class CommandTree: Creates a root-level submenu with no entries. SubMenu node is returned which can have submenus and commands attached to it. """ - # NOTE(MG) Fix for Python>=3.7, - # argparse.ArgumentParser added 'required' argument. - # Must also be written into SubMenu.create_submenu. func_args = {"dest": param_name, "metavar": param_name, "required": is_required} - if sys.version_info.major == 3 and sys.version_info.minor < 7: - if is_required: - _bootstrap_logger.warn( - "Unable to enforce required submenu: Requires >= Python 3.7" - ) - del func_args["required"] - # END fix for Python<3.7 # Creates an argument as a slot in the underlying argparse. subparsers = self.root_parser.add_subparsers(**func_args) @@ -211,6 +201,12 @@ class CommandTree: return None, None, False def run_command(self, args=None): + """ + Args: + args (list[str]): Direct from STDIN + Raises: + NoCommandSpecified for invalid command. + """ args, unk, success = self.parse(args) if not success: _bootstrap_logger.info("cli - SystemExit: Perhaps user invoked --help") @@ -226,7 +222,7 @@ class CommandTree: cmd = self._lookup_command(args) if cmd is None: _bootstrap_logger.critical("cli - Failed to find command.") - return False + raise NoCommandSpecified return self._invoke_command(cmd, args)