in knack/commands.py [0:0]
def __init__(self, command_loader, group_name, operations_tmpl, **kwargs):
""" Context manager for registering commands that share common properties.
:param command_loader: The command loader that commands will be registered into
:type command_loader: knack.commands.CLICommandsLoader
:param group_name: The name of the group of commands in the command hierarchy
:type group_name: str
:param operations_tmpl: The template for handlers for this group of commands (e.g. '__main__#{}')
:type operations_tmpl: str
:param kwargs: Kwargs to apply to all commands in this group.
Possible values: `client_factory`, `arguments_loader`, `description_loader`, `description`,
`formatter_class`, `table_transformer`, `deprecate_info`, `validator`, `confirmation`.
"""
self.command_loader = command_loader
self.group_name = group_name
self.operations_tmpl = operations_tmpl
self.group_kwargs = kwargs
Deprecated.ensure_new_style_deprecation(self.command_loader.cli_ctx, self.group_kwargs, 'command group')
if kwargs['deprecate_info']:
kwargs['deprecate_info'].target = group_name
is_preview = kwargs.get('is_preview', False)
is_experimental = kwargs.get('is_experimental', False)
if is_preview and is_experimental:
raise CLIError(PREVIEW_EXPERIMENTAL_CONFLICT_ERROR.format("command group", group_name))
if is_preview:
kwargs['preview_info'] = PreviewItem(
cli_ctx=self.command_loader.cli_ctx,
target=group_name,
object_type='command group'
)
if is_experimental:
kwargs['experimental_info'] = ExperimentalItem(
cli_ctx=self.command_loader.cli_ctx,
target=group_name,
object_type='command group'
)
command_loader._populate_command_group_table_with_subgroups(group_name) # pylint: disable=protected-access
self.command_loader.command_group_table[group_name] = self