コード例 #1
0
    def wrapper(ctx: Context, *args, **kwargs) -> None:
        """Work with given function"""

        msg = function(*args, **kwargs)

        if msg.get("always_print", True) or ctx.obj.get(
                "invoked_internally_by") not in ctx.obj.get(
                    "do_not_print_when_invoked_by", []):
            echo_wr(msg)

        if msg.get("err"):
            ctx.abort()
コード例 #2
0
    def resolve_command(self: MultiCommand, ctx: Context, args):
        cmd_name = make_str(args[0])
        original_cmd_name = cmd_name

        # Get the command
        cmd = self.get_command(ctx, cmd_name)

        # If we can't find the command but there is a normalization
        # function available, we try with that one.
        if cmd is None and ctx.token_normalize_func is not None:
            cmd_name = ctx.token_normalize_func(cmd_name)
            cmd = self.get_command(ctx, cmd_name)

        # Command not found
        if cmd is None and not ctx.resilient_parsing:
            PrettyHelper.VerifyCommand(self, ctx)
            ctx.abort()

            # if split_opt(cmd_name)[0]:
            #     self.parse_args(ctx, ctx.args)
            # ctx.fail("No such command '{}'.".format(original_cmd_name))

        return cmd_name, cmd, args[1:]
コード例 #3
0
ファイル: cli.py プロジェクト: ISafd/auto_player
def abort_if_false(ctx: Context, _: Union[Option, Parameter],
                   value: Any) -> Any:
    if not value:
        ctx.abort()