Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: AIP accepted!

Status

Page properties


StateVotingAccepted
InRelease
Discussion Thread

[VOTE] AIP-16: CLI: Use nested commands instead of flags

CLI: Use nested commands instead of flags

JIRA

Jira
serverASF JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyAIRFLOW-3998

Created

Created



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?