refactor(cli): Replace af api flags with subcommands
#76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the
af apicommand to use subcommands instead of flags for listing endpoints and fetching the OpenAPI spec:af api --endpoints→af api lsaf api --endpoints --filter var→af api ls --filter varaf api --spec→af api specDesign rationale
Why subcommands instead of flags?
Aligns with CLI conventions where distinct operations are subcommands (like
git remote addvsgit remote -a). Thelsandspecoperations are semantically different from making API calls.Why not use Typer's native subcommand feature?
Typer processes positional arguments before checking subcommands. With formal subcommands registered,
af api dags -F limit=10would fail with "No such command 'dags'". Instead, we detect reserved names (ls,spec) in the main handler and dispatch to internal functions.Why move OpenAPI fetching to adapters?
The original CLI code had AF2/AF3 fallback logic (try
/openapi.json, fall back to/api/v1/openapi.yaml). This version-specific behavior belongs in adapters, following the existing pattern for all other Airflow operations.Usage
Gotchas
lsandspecare reserved endpoint names. If Airflow ever adds actual/lsor/specendpoints, users would needaf api /ls --rawto access them directly.