-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add raw_result to CommandResultItem #235
Conversation
@@ -236,7 +236,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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send the full CommandResultItem
in case post-output hint relies on other attributes:
Lines 23 to 32 in 587abe5
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, 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add another parameter into EVENT_CLI_SUCCESSFUL_EXECUTE
to keep cmd_result
instead of overwrite the value of result
?
Although azure-cli
didn't use EVENT_CLI_SUCCESSFUL_EXECUTE
event now, but I'm afraid some other cli depend on knack might face breaking change in result
type. Since event handler func usually use func(*arg, **kwargs)
so adding new paremeter won't cause breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding arg in function invocation may also trigger breaking change if the callee doesn't accept the new arg.
We never guaranteed there will be no breaking changes:
https://github.com/microsoft/knack
The project is in initial development phase. We recommend pinning to at least a specific minor version when marking knack as a dependency in your project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok with me if breaking change is acceptable😆
Add
raw_result
toCommandResultItem
, so that the raw result (before query) can be used by post-output hint (Azure/azure-cli#16242).