I can write the following:
import click
@click.command()
@click.option('--things', callback=lambda _,__,x: x.split(',') if x else [])
def fun(things):
print('You gave me these things: {}'.format(things))
if __name__ == '__main__':
fun()
This appears to work, at least if I save it as fun.py
I can run:
$ python fun.py
You gave me these things: []
$ python fun.py --things penguins,knights,"something different"
You gave me these things: ['penguin', 'knights', 'something different']
Is there a more idiomatic way to write this code using Click, or is that pretty much it?