I’ve got a Python CLI app using Click. I have one command in which I defined various options.
This command loads up one of several available environments. (These are reinforcement learning environments, but that doesn’t matter for the purpose of this question.) There is an option --env
that chooses which environment to load and use. Each environment has different options that I want the user to be able to specify. However, I can’t quite define them as options on my command, since I don’t know in advance which environment the user will choose.
How can I have my CLI app accept these options?
Possible solutions that I find too ugly:
- Define options for all possible environments on the main command.
- Pass some kind of string that specifies all the environment options:
--env-options "foo=bar baz=7"
.