Esempio n. 1
0
    def parse_args(self: Command, ctx: Context, args: List[str],
                   supportsLiterals: Callable[[click.Parameter], bool]):
        if not args and self.no_args_is_help and not ctx.resilient_parsing:
            click.echo(ctx.get_help(), color=ctx.color)
            ctx.exit()

        args = PrettyHelper.parse_line(args)
        ctx.original_params = args.copy()

        parser = self.make_parser(ctx)
        opts, args, param_order = parser.parse_args(args=args)
        ctx.original_args = args.copy()

        i = 0
        for param in iter_params_for_processing(param_order,
                                                self.get_params(ctx)):
            if supportsLiterals(param):
                value, args, i = param.handle_parse_result(ctx, opts, args, i)
            else:
                value, args = param.handle_parse_result(ctx, opts, args)

        if args and not ctx.allow_extra_args and not ctx.resilient_parsing:
            ctx.fail("Got unexpected extra argument{} ({})".format(
                "s" if len(args) != 1 else "", " ".join(map(make_str, args))))

        ctx.args = args
        return args
Esempio n. 2
0
def print_version(ctx: Context, param: Option, value: bool) -> None:
    """
    Print version information of cli
    :param ctx: click context
    :param param: current parameter's metadata
    :param value: value of current parameter
    """
    if not value or ctx.resilient_parsing:
        return
    click.echo('{title}, version {version}.'.format(title=__TITLE__.capitalize(), version=__VERSION__))
    click.echo('Developed by {author}, {email}.'.format(author=__AUTHOR__, email=__AUTHOR_EMAIL__))
    ctx.exit()
Esempio n. 3
0
def print_version(ctx: Context, param: Option, value: bool):
    if not value or ctx.resilient_parsing:
        return
    click.echo('{title}, version {version}.'.format(title=__TITLE__.capitalize(), version=__VERSION__))
    ctx.exit()
Esempio n. 4
0
def print_version(ctx: Context, param: Option, value: bool) -> None:
    """Prints the version"""
    if not value or ctx.resilient_parsing:
        return
    click.echo(VERSION)
    ctx.exit()
Esempio n. 5
0
def print_version(ctx: Context, param, value):
    if not value or ctx.resilient_parsing:
        return

    print(__version__)
    ctx.exit()