I've recently started developing unix tools with config passed entirely as arguments with a special argument called `--args-file` which takes a file or stdin and reads one arg per line.
This is of course nothing new, but such a powerful pattern:
- It lets you run things without the need for a config file (when testing/running interactively)
- but on the other hand, you can still define arguments saved in a file for more permanent setups.
- `--help` ends up providing all the doc needed to configure the tool.
- It's less magical than env vars and doesn't leak into subprocesses by mistake.
One pragmatic step further is to expand env vars using the shell `${VAR}` syntax for slightly more flexibility.
This is of course nothing new, but such a powerful pattern:
- It lets you run things without the need for a config file (when testing/running interactively)
- but on the other hand, you can still define arguments saved in a file for more permanent setups.
- `--help` ends up providing all the doc needed to configure the tool.
- It's less magical than env vars and doesn't leak into subprocesses by mistake.
One pragmatic step further is to expand env vars using the shell `${VAR}` syntax for slightly more flexibility.