def get_command(self, ctx, command_name):
# if command_name == "BREAK":
# return click.Command("BREAK", help="marker")
options_list = self.get_commands()[command_name]["options"]
key_map = self.commands[command_name]["key_map"]
tasks = self.commands[command_name]["tasks"]
task_vars = self.commands[command_name]["vars"]
default_vars = self.commands[command_name]["default_vars"]
doc = self.commands[command_name]["doc"]
args_that_are_vars = self.commands[command_name]["args_that_are_vars"]
value_vars = self.commands[command_name]["value_vars"]
metadata = self.commands[command_name]["metadata"]
def command_callback(**kwargs):
new_args, final_vars = get_vars_from_cli_input(kwargs, key_map, task_vars, default_vars, args_that_are_vars,
value_vars)
return {"name": command_name, "vars": final_vars, "metadata": metadata}
help = doc.get("help", "n/a")
short_help = doc.get("short_help", help)
epilog = doc.get("epilog", None)
command = click.Command(command_name, params=options_list, help=help, short_help=short_help, epilog=epilog,
callback=command_callback)
return command
评论列表
文章目录