Thanks for your reply. But I still don't quite understand the tutorial you referenced. Can you walk me through the example in the following?
snippsat
Just the fact that click.echo(''),
has full Unicode support and you will get correct output in all OS(also in Windows cmd where Unicode always has been wrong).[/quote]
#test.py import click def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return click.echo('Version 1.0') ctx.exit() @click.command() @click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True) def main(): click.echo('Hello world') if __name__ == '__main__': main()In my example, what will be passed to param and value separately in the callback function print_version?
snippsat
(Oct-09-2016, 08:57 AM)dullboy Wrote: Thanks for your reply. But how are param and value passed to the callback function print_version?It's explained here.
Quote:Not familiar with click, but as it says, try adding param to the callback signature.It's pretty impressive,it blows other command line parser out the window :whistle:
Just the fact that click.echo(''),
has full Unicode support and you will get correct output in all OS(also in Windows cmd where Unicode always has been wrong).[/quote]