1
如何爲同一選項指定短期權和長期權? 例如,對於下面,我也想用-c
爲--count
:如何在點擊中爲一個選項創建短期和長期期權?
import click
@click.command()
@click.option('--count', default=1, help='count of something')
def my_command(count):
click.echo('count=[%s]' % count)
if __name__ == '__main__':
my_command()
例如,
$ python my_command.py --count=2
count=[2]
$ python my_command.py -c 3
count=[3]
參考文獻:
click documentation in a single pdf
click sourcecode on github
click website
click PyPI page
完美!謝謝@Stephen_Rauch! –