Click: Required boolean option?

Created on 3 Oct 2015  路  1Comment  路  Source: pallets/click

Is there any way to specify that a boolean option is required, i.e. to not have it default to False?

I'd like to do something like

@click.option('--pre-deploy/--post-deploy', 'pre_deploy', required=True)

And complain if the user doesn't specify one of the flags. Currently we default to None and check that pre_deploy is not None.

Most helpful comment

Ach, looks like default=None, required=True works!

@click.option('--pre-deploy/--post-deploy', 'pre_deploy', default=None, required=True)

>All comments

Ach, looks like default=None, required=True works!

@click.option('--pre-deploy/--post-deploy', 'pre_deploy', default=None, required=True)
Was this page helpful?
0 / 5 - 0 ratings