def execute(context): # choose which module(s) to look for command if context.args.built_in: modules = [BUILTIN_MODULE] elif context.args.module: modules = [context.args.module] else: modules = list_modules() matched_commands = [] for module_name in modules: commands = load_commands_from_module(module_name) found_command = commands.get(context.args.command, None) if found_command: matched_commands.append(found_command) if len(matched_commands) == 0: log.error("Command %s is not found" % context.args.command) return False elif len(matched_commands) == 1: matched_commands[0].show_help() else: log.title("Found multiple commands") log.write("Use suggested argument to show help for specified command only.") for command in matched_commands: if command.module_name == BUILTIN_MODULE: narrow_help = "run with --built-in" else: narrow_help = "run with --module=%s" % command.module_name log.write(" " * 4 + "%-25s%s" % (str(command), narrow_help)) return True
def execute(context): aliases = load_aliases() log.title("Found %d alias(es)" % len(aliases)) for alias, alias_to in sorted(aliases.items()): log.write(" " * 4 + ("%-20s " + log.GRAY + "%s" + log.END) % (alias, alias_to)) return True
def execute(context): modules = module.list_modules() modules.remove(BUILTIN_MODULE) log.title("Found %d module(s)" % len(modules)) for module_name in sorted(modules): log.write(" " * 4 + module_name) return True
def print_module_with_commands(module_name, module_commands): log.title(module_name) for command_name, command in sorted(module_commands.items()): log.write(" " * 4 + ("%-25s " + log.GRAY + "%s" + log.END) % (str(command), command.get_short_description()))