I am trying to use https://click.palletsprojects.com/en/8.0.x/options/
I have a use case where one out of these 3 parameters has to be a required field.
This is how I am doing it.
10:45 $ python test.py Usage: test.py [OPTIONS]
Error: Must specify --foo or bar or car
import click
@click.command()
@click.option('--foo', help='foo is bar.')
@click.option('--count', help='Number of greetings.')
@click.option('--name',
              help='The person to greet.')
def hello(foo, count, name):
    if not (count or name or foo):
        raise click.UsageError( 'Must specify --foo or bar or car')
    
    
    click.echo(f"Hello {name}!")
if __name__ == '__main__':
    hello()
Is there a way to show one of these params as required field. something like this:
python test.py --help
Usage: test.py [OPTIONS]
Options:
  --foo TEXT    foo is bar
 or --count TEXT  Number of greetings
 or  --name TEXT   The person to greet [required]
  --help        Show this message and exit.
Try 1:
https://click.palletsprojects.com/en/8.0.x/options/#feature-switches
import click
@click.command()
@click.option('--foo', flag_value='foo', required=True, help='foo is bar.')
@click.option('--count', flag_value='count', required=True, help='Number of greetings.')
@click.option('--name', flag_value='name', required=True, help='The person to greet.')
def hello(foo, count, name):
    if not (count or name or foo):
        raise click.UsageError( 'Must specify --foo or bar or car')
    if foo:
        click.echo(f"Hello {foo}!")
    if count:
        click.echo(f"Hello {count}!")
    if name:
        click.echo(f"Hello {name}!")
if __name__ == '__main__':
    hello()
 
    