Beispiel #1
0
def _get_lazyload_commands(multicommand: click.MultiCommand, ) -> Dict[str, Optional[click.Command]]:
	commands = {}

	for command in multicommand.list_commands(multicommand):  # type: ignore
		commands[command] = multicommand.get_command(multicommand, command)  # type: ignore

	return commands
Beispiel #2
0
def _get_lazyload_commands(
        multicommand: click.MultiCommand) -> Dict[str, click.Command]:
    """Obtains click.Command references to the subcommands of a given command"""
    commands = {}
    for command in multicommand.list_commands(multicommand):
        commands[command] = multicommand.get_command(multicommand, command)

    return commands
Beispiel #3
0
Datei: cli.py Projekt: eyalev/lk
    def __init__(self, **kwargs):

        MultiCommand.__init__(self, **kwargs)

        self.user_commands_dir = ConfigUtil().user_commands_directory
        self.core_commands_dir = ConfigUtil().core_commands_directory

        self.commands = self._init_commands()
        # self.commands = self._init_commands_new()

        self._repo = None
Beispiel #4
0
def walk_commands(
    ctx: click.Context,
    multicommand: click.MultiCommand,
    name_trail: Tuple[str, ...] = (),
) -> Iterable[Tuple[Tuple[str, ...], Command]]:
    for subcommand in multicommand.list_commands(ctx):
        cmd = multicommand.get_command(ctx, subcommand)
        assert cmd is not None
        new_name_trail = name_trail + (cmd.name, )
        yield (new_name_trail, cmd)
        if isinstance(cmd, click.MultiCommand):
            yield from walk_commands(ctx, cmd, new_name_trail)
Beispiel #5
0
    def __init__(self, commands_dir, **kwargs):
        MultiCommand.__init__(self, **kwargs)

        self._commands_dir = commands_dir
Beispiel #6
0
def iterCommands(ctx: Context, parent: MultiCommand) -> Iterator[Command]:
    for name in parent.list_commands(ctx):
        command = parent.get_command(ctx, name)
        assert command is not None, name
        yield command