cookiecutter-python-app icon indicating copy to clipboard operation
cookiecutter-python-app copied to clipboard

Default value for `--config` in cli.py

Open LKirst opened this issue 11 months ago • 1 comments

First of all, thank you for the cookiecutter template! I have one question about cli.py: Should the default for args.config not be a list?

If I'm not mistaken, parser.add_argument("-c", "--config", action="append") creates a list, but the default is a string, not a list with a single string value:

https://github.com/mdklatt/cookiecutter-python-app/blob/02c1c78bd69bd9d3ec30396ed0bc2455164d2a78/%7B%7Bcookiecutter.project_slug%7D%7D/src/%7B%7Bcookiecutter.app_name%7D%7D/cli.py#L73

Would it not be easier to use a list as default args.config = ["etc/config.toml"], because then, I could always assume args.config is a list?

LKirst avatar Feb 10 '25 19:02 LKirst

Good catch, yes, this should be args.config = ["etc/config.toml"] if you want to allow multiple config files. In practice I usually only have one config file, so I never noticed this mistake.

If you change this, be aware that there are other places that only expect a single value for args.config, e.g.

https://github.com/mdklatt/cookiecutter-python-app/blob/02c1c78bd69bd9d3ec30396ed0bc2455164d2a78/%7B%7Bcookiecutter.project_slug%7D%7D/src/%7B%7Bcookiecutter.app_name%7D%7D/cli.py#L26

mdklatt avatar Feb 11 '25 18:02 mdklatt