Skip to content

fix(base): do not register --sort flag on list commands without sorting - #1549

Open
zerone0x wants to merge 1 commit into
hetznercloud:mainfrom
zerone0x:fix/list-hide-unsupported-sort
Open

zerone0x wants to merge 1 commit into
hetznercloud:mainfrom
zerone0x:fix/list-hide-unsupported-sort

Conversation

@zerone0x

Copy link
Copy Markdown

Fixes #1536.

The --sort flag was registered on every list command, including those whose SortOption is nil (iso, network, server-type, load-balancer-type, storage-box-type). It now is only registered when sorting is supported, so it disappears from --help and the generated docs for those commands.

Because the flag no longer exists on those commands, the "resource does not support sorting. Ignoring --sort flag" warning in Run became unreachable and is removed; passing --sort there is now an unknown-flag error.

Changes:

  • internal/cmd/base/list.go: register --sort only if SortOption != nil; simplify sort handling in Run.
  • internal/cmd/base/list_test.go: test that the flag exists with a SortOption and not without (fails when the fix is reverted).
  • docs/reference/manual/*: regenerated with go generate ./...; only the 5 unsupported list commands changed, all other list commands keep --sort.

Checks run locally: go test ./... (all pass), golangci-lint run v2.15.0 on the changed package (0 issues), go generate ./... (docs up to date).

@zerone0x
zerone0x requested a review from a team as a code owner November 17, 2026 16:18
@jooola

jooola commented Nov 17, 2026

Copy link
Copy Markdown
Member

Please disclose any use of AI/LLMs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List command: --sort shown where sorting is unsupported

2 participants