From 51b4000062e307f663f4cb5a1e8d8b1e620617be Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Fri, 12 Nov 2021 16:34:33 +0800 Subject: [PATCH] Do not hard code --- knack/invocation.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/knack/invocation.py b/knack/invocation.py index afc29a1..46420b5 100644 --- a/knack/invocation.py +++ b/knack/invocation.py @@ -4,20 +4,20 @@ # -------------------------------------------------------------------------------------------- import sys - from collections import defaultdict -from .deprecation import ImplicitDeprecated, resolve_deprecate_info -from .preview import ImplicitPreviewItem, resolve_preview_info -from .experimental import ImplicitExperimentalItem, resolve_experimental_info -from .util import CLIError, CtxTypeError, CommandResultItem, todict -from .parser import CLICommandParser from .commands import CLICommandsLoader +from .deprecation import ImplicitDeprecated, resolve_deprecate_info from .events import (EVENT_INVOKER_PRE_CMD_TBL_CREATE, EVENT_INVOKER_POST_CMD_TBL_CREATE, EVENT_INVOKER_CMD_TBL_LOADED, EVENT_INVOKER_PRE_PARSE_ARGS, EVENT_INVOKER_POST_PARSE_ARGS, EVENT_INVOKER_TRANSFORM_RESULT, EVENT_INVOKER_FILTER_RESULT) +from .experimental import ImplicitExperimentalItem, resolve_experimental_info from .help import CLIHelp +from .log import CLILogging +from .parser import CLICommandParser +from .preview import ImplicitPreviewItem, resolve_preview_info +from .util import CLIError, CtxTypeError, CommandResultItem, todict class CommandInvoker(object): @@ -137,7 +137,8 @@ def execute(self, args): self.parser.load_command_table(self.commands_loader) self.cli_ctx.raise_event(EVENT_INVOKER_CMD_TBL_LOADED, parser=self.parser) - arg_check = [a for a in args if a not in ['--verbose', '--debug', '--only-show-errors']] + arg_check = [a for a in args if a not in + (CLILogging.DEBUG_FLAG, CLILogging.VERBOSE_FLAG, CLILogging.ONLY_SHOW_ERRORS_FLAG)] if not arg_check: self.cli_ctx.completion.enable_autocomplete(self.parser) subparser = self.parser.subparsers[tuple()]