Skip to content

Commit

Permalink
Add raw_result to CommandResultItem (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli authored Mar 25, 2021
1 parent 4830dab commit 03b46ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion knack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,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)
self.raise_event(EVENT_CLI_SUCCESSFUL_EXECUTE, result=cmd_result)
except KeyboardInterrupt as ex:
exit_code = 1
self.result = CommandResultItem(None, error=ex, exit_code=exit_code)
Expand Down
3 changes: 2 additions & 1 deletion knack/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,5 @@ def execute(self, args):
return CommandResultItem(event_data['result'],
exit_code=0,
table_transformer=cmd_tbl[parsed_args.command].table_transformer,
is_query_active=self.data['query_active'])
is_query_active=self.data['query_active'],
raw_result=cmd_result)
4 changes: 3 additions & 1 deletion knack/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@

class CommandResultItem(object): # pylint: disable=too-few-public-methods
def __init__(self, result, table_transformer=None, is_query_active=False,
exit_code=0, error=None):
exit_code=0, error=None, raw_result=None):
self.result = result
self.error = error
self.exit_code = exit_code
self.table_transformer = table_transformer
self.is_query_active = is_query_active
# The result before applying query
self.raw_result = raw_result


class CLIError(Exception):
Expand Down

0 comments on commit 03b46ab

Please sign in to comment.