Add support for URL completions in buf curl#4402
Open
stefanvanburen wants to merge 5 commits intomainfrom
Open
Add support for URL completions in buf curl#4402stefanvanburen wants to merge 5 commits intomainfrom
buf curl#4402stefanvanburen wants to merge 5 commits intomainfrom
Conversation
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.
Contributor
|
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
Member
Author
|
using the following vhs tape: Output curl-completion.gif
Set Shell fish
Set FontSize 14
Set Width 900
Set Height 400
Set Padding 16
Set Theme "Catppuccin Mocha"
Env PATH "/Users/stefanvanburen/.cache/buf/Darwin/arm64/gobin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
Hide
Sleep 1s
Type "source ~/.config/fish/completions/buf.fish"
Enter
Sleep 200ms
Show
Ctrl+L
Sleep 200ms
# --protocol flag: static completions (connect, grpc, grpcweb)
Type "buf curl --protocol "
Sleep 500ms
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# --reflect-protocol flag: static completions (grpc-v1, grpc-v1alpha)
Type "buf curl --reflect-protocol "
Sleep 500ms
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# URL via reflection — Tab 1: unambiguous prefix collapses to full service name
Type "buf curl https://demo.connectrpc.com/"
Sleep 500ms
Tab
Sleep 4s
# Tab 2: method completions (Converse, Introduce, Say)
Tab
Sleep 2s
# Select a method by typing a prefix and completing
Type "Say"
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# Same via --schema (no running server needed) — Tab 1: service name
Type "buf curl --schema buf.build/connectrpc/eliza https://demo.connectrpc.com/"
Sleep 500ms
Tab
Sleep 4s
# Tab 2: method completions
Tab
Sleep 2s
Ctrl+C |
via `go get buf.build/go/app@main`.
We've added descriptions to the URL completions about _where_ the completion is coming from (the local module, the schema flag, or gRPC reflection), which should help users understand better why they're getting completions. We've also added error handling, for now targeting issues with the `--schema` parameter.
Member
Author
|
Quick UX update: in 20a16ea I added descriptions to the RPC completions about where the schema is coming from (local module, reflection, --schema flag), and also added some basic error handling. Updated gif: via this tape: Output curl-completion.gif
Set Shell fish
Set FontSize 14
Set Width 900
Set Height 400
Set Padding 16
Set Theme "Catppuccin Mocha"
Env PATH "/Users/stefanvanburen/.cache/buf/Darwin/arm64/gobin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
Hide
Sleep 1s
Type "source ~/.config/fish/completions/buf.fish"
Enter
Sleep 200ms
Show
Ctrl+L
Sleep 200ms
# --protocol flag: static completions (connect, grpc, grpcweb)
Type "buf curl --protocol "
Sleep 500ms
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# --reflect-protocol flag: static completions (grpc-v1, grpc-v1alpha)
Type "buf curl --reflect-protocol "
Sleep 500ms
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# URL via reflection — Tab 1: unambiguous prefix collapses to full service name
Type "buf curl https://demo.connectrpc.com/"
Sleep 500ms
Tab
Sleep 4s
# Tab 2: method completions (Converse, Introduce, Say)
Tab
Sleep 2s
# Select a method by typing a prefix and completing
Type "Say"
Tab
Sleep 2s
Ctrl+C
Sleep 1s
# Same via --schema (no running server needed) — Tab 1: service name
Type "buf curl --schema buf.build/connectrpc/eliza https://demo.connectrpc.com/"
Sleep 500ms
Tab
Sleep 4s
# Tab 2: method completions
Tab
Sleep 2s
Ctrl+C |
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.


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
--schemaflag 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
ModifyCobraactually run: bufbuild/app-go#5. We'll want to land upstream tomainbefore 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
--schemavalues, either using local directories or BSR modules, and completions for--datavalues (if we know the schema and the specific RPC targeted by the URL, we know the shape of the JSON for the--dataflag). 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.