I am trying to build a cli with 2 sets of arguments using the Click extension click_option_group (https://github.com/click-contrib/click-option-group) . One group is the "server Configuration" and I can use the "option" with it for the "name". In the other group "My app Configuration", I want to use "argument". Can I use "argument" with optgroup for "app". So users can just pass a apps as arguments. I get an error "'_Optgroup' object has no attribute 'argument' " Is there a way to pass argument in optgroup ?
Here's the code:
import click
from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup, OptionGroup
@click.command()
@click.option('--outfile', '-o')
@optgroup.group('Server configuration', help='The configuration for Server')
@optgroup.option('--name', '-n', help='Server host name')
@optgroup.option('My app configuration', cls=RequiredMutuallyExclusiveOptionGroup, help='The configuration for my app')
@optgroup.argument('app', nargs=-1)
def cli(**params):
print(params)
def data(*args):
for a in args:
click.echo(a)
if __name__ == '__main__':
cli()