Skip to content
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

[Core] aaz: Support to use cli_ctx to initiate AAZCommand class #23459

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/azure-cli-core/azure/cli/core/aaz/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,24 @@ def _build_arguments_schema(cls, *args, **kwargs):
# schema.generic_update_force_string = AAZGenericUpdateForceString()
return schema

def __init__(self, loader):
def __init__(self, loader=None, cli_ctx=None, **kwargs):
"""

:param loader: it is required for command registered in the command table
:param cli_ctx: if a command instance is not registered in the command table, only cli_ctx is required.
"""
assert loader or cli_ctx, "loader or cli_ctx is required"
self.loader = loader
super().__init__(
cli_ctx=loader.cli_ctx,
cli_ctx=cli_ctx or loader.cli_ctx,
name=self.AZ_NAME,
confirmation=self.AZ_CONFIRMATION,
arguments_loader=self._cli_arguments_loader,
handler=True,
# knack use cmd.handler to check whether it is group or command,
# however this property will not be used in AAZCommand. So use True value for it.
# https://github.com/microsoft/knack/blob/e496c9590792572e680cb3ec959db175d9ba85dd/knack/parser.py#L227-L233
**kwargs
)
self.command_kwargs = {}

Expand Down