Status
State: Draft
Discussion thread: https://lists.apache.org/thread.html/94c97ed621706a2e9130a3550b879a5838c23209f2d6d40f8bb49cd8@%3Cdev.airflow.apache.org%3E
JIRA: https://issues.apache.org/jira/browse/AIRFLOW-3998
Motivation
The CLI treats `airflow connection` as a single command, with `--list`, `--add`, etc. as flags. This means it's possible to pass options that can't be used together: passing `--list` with `--conn_id` should be invalid. Different flags are also required for listing, adding, and deleting connections. The current implementation has to handle validation of required, invalid, and mutually exclusive options separately for each command. I think the code would be simpler and easier to use if we used nested commands instead of flags: `airflow connections list` and `airflow connections add` would be separate subcommands that would take different arguments, and we wouldn't have to check for invalid combinations of commands and arguments.
Considerations
- If we're thinking of additional refactoring for the cli module, such as using `click` instead of `argparse`, we might want to combine these changes.
- It might be possible to make this change without breaking backwards compatibility, but that would make the code a bit more complicated. Should we prefer simpler code or compatibility?