diff --git a/knack/cli.py b/knack/cli.py index 439ed8f..64e7618 100644 --- a/knack/cli.py +++ b/knack/cli.py @@ -15,7 +15,7 @@ from .util import CLIError from .config import CLIConfig from .query import CLIQuery -from .events import EVENT_CLI_PRE_EXECUTE, EVENT_CLI_POST_EXECUTE +from .events import EVENT_CLI_PRE_EXECUTE, EVENT_CLI_SUCCESSFUL_EXECUTE, EVENT_CLI_POST_EXECUTE from .parser import CLICommandParser from .commands import CLICommandsLoader from .help import CLIHelp @@ -219,6 +219,7 @@ def invoke(self, args, initial_invocation_data=None, out_file=None): if cmd_result and cmd_result.result is not None: formatter = self.output.get_formatter(output_type) self.output.out(cmd_result, formatter=formatter, out_file=out_file) + self.raise_event(EVENT_CLI_SUCCESSFUL_EXECUTE, result=cmd_result.result) except KeyboardInterrupt as ex: exit_code = 1 self.result = CommandResultItem(None, error=ex, exit_code=exit_code) diff --git a/knack/events.py b/knack/events.py index f157d32..23d8669 100644 --- a/knack/events.py +++ b/knack/events.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------------------------- EVENT_CLI_PRE_EXECUTE = 'Cli.PreExecute' +EVENT_CLI_SUCCESSFUL_EXECUTE = 'Cli.SuccessfulExecute' EVENT_CLI_POST_EXECUTE = 'Cli.PostExecute' EVENT_INVOKER_PRE_CMD_TBL_CREATE = 'CommandInvoker.OnPreCommandTableCreate'