Wang1rrr opened a new issue, #5142: URL: https://github.com/apache/rocketmq-dashboard/issues/5142
# [rmqctl][Enhancement] Complete local contexts and catalog enum values in the existing shell completion ## Problem `rmqctl` already provides Cobra completion scripts for Bash, Zsh, Fish and PowerShell, and `explain <resource>` completes catalog resource names. Completion stops short of several values the CLI already knows locally: context names, output formats and catalog enum fields. On `rocketmq-studio` at `4ee173ad71ae777f01111394a88358958b9abad6`, the following completion requests return no candidates and the default directive (`:0`), which allows the shell to fall back to filesystem completion: ```text rmqctl __complete topic list --type "" :0 rmqctl __complete topic list --type F :0 rmqctl __complete --output j :0 rmqctl __complete --config ./contexts.yaml --context s :0 rmqctl __complete --config ./contexts.yaml config use-context s :0 ``` The context fixture contains `production` and `staging`, with valid `env:NAME` credential references whose environment variables are unset. For comparison, `rmqctl __complete explain to` already returns `topic` followed by `:4` (`ShellCompDirectiveNoFileComp`). This makes operators look up valid topic types or context names while tab completion offers unrelated files. The data needed to improve this behavior already exists in the local config and the generated tool catalog. ## Proposed scope Extend the existing completion callbacks; no new command, server API, dependency or catalog format is required. - Complete the global `--context` flag and the first argument of `config use-context`, `config delete-context` and `config set-context`, including their existing aliases, from the selected config's context names. Respect the existing `--config` / `RMQCTL_CONFIG` / default path precedence. `set-context` would still accept new names. - Complete catalog string flags that declare an enum using `Field.Enum`, including enum leaves reached by the existing object-schema traversal. Current examples include `topic list --type`, `topic update --type` / `--perm` and consumer subscription/consume modes. Do not introduce a second list of enum values or mutate the shared catalog slices. - Complete `--output` / `-o` using the existing `table`, `json` and `yaml` formats. - Return deterministic, prefix-filtered candidates and `NoFileComp` for these non-file values, including the empty-result case. Keep normal file completion for `--config`. Completion must remain local and read-only. It must not resolve credentials, require `--instance-id`, prompt for approval, contact Studio, write config, or print server URLs/credential references. Missing config should yield no context candidates; invalid/unreadable config should return an error completion directive together with `NoFileComp`, without contaminating candidate stdout. Context names containing control characters must not inject extra completion records or directives. Remote completion of instance IDs, topics and consumer groups is deliberately out of scope: it would require network/authentication behavior and a separate design discussion. ## Validation plan - Exercise Cobra's real `__complete` entry point, not only helper functions: exact candidates, prefix matching, aliases, no candidates, second positional arguments and directives. - Verify config path precedence, no selected current context, missing/invalid config, Unicode/space-containing context names and rejection of control characters in completion records. - Use a recording/failing HTTP transport and environment lookup stub to prove every completion path remains offline and never reads credential values or writes config. - Verify enum completion against catalog fields (including a nested schema fixture) and assert the shared catalog remains unchanged. - Generate all four existing shell scripts and smoke-check the completion protocol; add concise installation/examples documentation. - Run focused command/config tests, full Go tests, formatting, catalog verification, `go vet`, race checks and supported builds; report baseline failures separately. ## Scope feedback requested Would this local-only completion extension fit the intended rmqctl workflow? I would like maintainer feedback on the context commands and invalid-config completion behavior before implementation is finalized. This proposal does not seek to change command execution or the explicit instance-selection contract. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
