Allow ModifyCobra to modify subcommands#5
Merged
stefanvanburen merged 1 commit intomainfrom Mar 19, 2026
Merged
Conversation
As written, ModifyCobra will only apply to the root command. This fixes this so that a subcommand with a ModifyCobra field will have it applied. I realize this is a break-glass feature, but currently it's the only way for a command to modify its completions, which I'm looking to modify upstream for things like bufbuild/buf#2044. It also uses the builtin `max` as a cleanup; if we end up landing this, I plan to come back here to upgrade this repository.
stefanvanburen
added a commit
to bufbuild/buf
that referenced
this pull request
Mar 19, 2026
First mentioned in #2044, which is long something I've wanted. This adds support for completing URLs based on the available RPCs, which either comes from the existing `--schema` flag or gRPC reflection. The completion itself works somewhat similar to LSP completion, in that it attempts to complete as far as it can before giving the user an option between the remaining values to disambiguate. It will complete up to the entire service URL, and then provide completions for RPCs within the service (if there are multiple). This requires one fix upstream in app-go so that subcommands that define `ModifyCobra` actually run: bufbuild/app-go#5. We'll want to land upstream to `main` before landing this. Open to suggestions on the completion UX. It feels fairly natural to me currently, but I'm sure there are edge cases. Future work here could include better completions for `--schema` values, either using local directories or BSR modules, and completions for `--data` values (if we know the schema and the specific RPC targeted by the URL, we know the shape of the JSON for the `--data` flag). Also, following this pattern of using ModifyCobra, other commands could be made to have better contextual completion. Also fixes the buf curl help examples to have consistent indentation. Resolves #2044.
emcfarlane
approved these changes
Mar 19, 2026
Member
Author
|
Regardless if bufbuild/buf#4402 is merged or not, I'd argue that this is a bug fix (since all subcommands can define a |
stefanvanburen
added a commit
that referenced
this pull request
Mar 19, 2026
Follow up to #5. This upgrades: * `buf` to latest * `golangci-lint` to match buf's version, up to v2 * Fixes some minor lints * go.mod version to 1.25.0 (n-1) * Add 2026 to copyright years
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As written, ModifyCobra will only apply to the root command. This fixes this so that a subcommand with a ModifyCobra field will have it applied.
I realize this is a break-glass feature, but currently it's the only way for a command to modify its completions, which I'm looking to modify upstream for things like bufbuild/buf#2044.
It also uses the builtin
maxas a cleanup; if we end up landing this, I plan to come back here to upgrade this repository.