Python Click Library Rename Argument

后端 未结 2 1789
既然无缘
既然无缘 2021-01-18 15:07

I am using the Click library but I can\'t seem to find a behavior similar to dest from argparse.

For example, I have

2条回答
  •  野的像风
    2021-01-18 15:26

    Renaming an option to a differently named function argument is possible by decorating the function with

    @click.option('--format', '-f', 'format_arg_name')
    def plug(format_arg_name):
        print(format_arg_name)
    

    then it will remap the option named format and make it available as the format_arg_name parameter.

    format_arg_name will not be available as a command line option, but --format and -f are.

提交回复
热议问题