frecklecute_cli.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:freckles 作者: makkus 项目源码 文件源码
def __init__(self, current_command, config, **kwargs):
        """Base class to provide a command-based (similar to e.g. git) cli for frecklecute.

        This class parses the folders in the paths provided by the config
        element for so-called 'frecklecutables', (yaml) text files that contain a list of tasks and optionally command-line argument descriptions. More information: XXX

        Args:
          current_command (tuple): a tuple in the format (command_name, command_path), which is used for commands that are paths, instead of filenames in one of the known frecklecutable paths. Can be (None, None) if not a path.
          config (FrecklesConfig): the config wrapper object
          kwargs (dict): additional arguments that are forwarded to the partent click.MultiCommand constructor
        """

        click.MultiCommand.__init__(self, "freckles", **kwargs)

        output_option = click.Option(param_decls=["--output", "-o"], required=False, default="default",
                                     metavar="FORMAT", type=click.Choice(SUPPORTED_OUTPUT_FORMATS),
                                     help="format of the output", is_eager=True)
        ask_become_pass_option = click.Option(param_decls=["--ask-become-pass", "-pw"],
                                              help='whether to force ask for a password, force ask not to, or let try freckles decide (which might not always work)',
                                              type=click.Choice(["auto", "true", "false"]), default="auto")
        version_option = click.Option(param_decls=["--version"], help='prints the version of freckles', type=bool,
                                      is_flag=True, is_eager=True, expose_value=False, callback=print_version)
        no_run_option = click.Option(param_decls=["--no-run"],
                                     help='don\'t execute frecklecute, only prepare environment and print task list',
                                     type=bool, is_flag=True, default=False, required=False)
        use_repo_option = click.Option(param_decls=["--use-repo", "-r"], required=False, multiple=True, help="extra context repos to use", is_eager=True, callback=download_extra_repos, expose_value=True)

        self.params = [use_repo_option, output_option, ask_become_pass_option, no_run_option, version_option]

        self.config = config
        # .trusted_repos = DEFAULT_FRECKLES_CONFIG.trusted_repos
        # local_paths = get_local_repos(trusted_repos, "frecklecutables")

        self.command_repo = CommandRepo(config=self.config, additional_commands=[current_command])
        self.current_command = current_command[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号