whisk.cli.whisk_multi_command

Module Contents

Classes

WhiskMultiCommand

This is a custom class based on

class whisk.cli.whisk_multi_command.WhiskMultiCommand(name: Optional[str] = None, invoke_without_command: bool = False, no_args_is_help: Optional[bool] = None, subcommand_metavar: Optional[str] = None, chain: bool = False, result_callback: Optional[Callable[Ellipsis, Any]] = None, **attrs: Any)[source]

Bases: click.MultiCommand

This is a custom class based on https://github.com/pallets/click/blob/master/examples/complex/complex/cli.py that loads click command files at run time from both the whisk module commands and commands specified within the created project. This lets users override existing whisk cli commands and create new commands.

Project-specific commands are only loaded if the the cwd is the project root.

core_commands_dir(self)[source]

Commands available whether in or outside a project.

core_project_commands_dir(self)[source]

whisk-provided project-only commands directory.

project_commands_dir(self)[source]

Custom project commands directory.

list_commands(self, ctx)[source]

MultiCommand classes must implement this function. This returns a set of file names across all directories.

_command_file_names(self, dir_name)[source]

Returns a list of file names minus the *.py file extension. This assumes that click commands are listed in directories containing only click command files.

_eval_file(self, fn)[source]

Evals the given filename, return the ‘cli’ namespace. The file must contain a ‘cli’ click command or group.

If the file doesn’t exist, nothing is returned.

get_command(self, ctx, name)[source]

MultiCommand classes must implement this function.

Returns the CLI command w/the given name. The following load order is used: * Project-specific commands * Core commands * Core project-specific commands

If a command is found it is returned immediately. For example, if both a custom project-specific command and a core project-specific command exist with the same name the custom command is returned, overriding the default.