Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cobra-cli support #10293

Merged
merged 2 commits into from Feb 10, 2024

Conversation

EmilyGraceSeville7cf
Copy link
Contributor

Description

https://github.com/spf13/cobra-cli/blob/main/README.md

Fixes issue #

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

@EmilyGraceSeville7cf
Copy link
Contributor Author

EmilyGraceSeville7cf commented Feb 10, 2024

I expected eval (cobra-cli completion fish) to work, but it didn't for some reason: no completion appeared after this command was entered in the interactive Fish session. Can somebody explain why it failed to work? cobra-cli completion fish writes output to stdout, so I expected eval to correctly interpret its output. What am I missing?

@faho
Copy link
Member

faho commented Feb 10, 2024

What you actually want is a third thing:

cobra-cli completion fish | source

This is also what our completions for e.g. starship or deno do

Here's why eval didn't work:

echo "echo foo
echo bar" > script

Now run eval (cat script). This ends up running eval "echo foo" "echo bar", only eval doesn't care about separate arguments (if it did eval echo foo would run an empty echo and then a command foo). It ends up running echo foo echo bar, printing "foo echo bar".

The first line of the output of cobra-cli completion fish is a comment, so eval sees one big comment and does nothing.

@faho faho added this to the fish next-3.x milestone Feb 10, 2024
@faho faho merged commit 623f346 into fish-shell:master Feb 10, 2024
6 of 7 checks passed
@faho
Copy link
Member

faho commented Feb 10, 2024

Thanks!

@zanchey zanchey modified the milestones: fish next-3.x, fish 3.7.1 Mar 18, 2024
zanchey pushed a commit that referenced this pull request Mar 18, 2024
* feat: cobra-cli support

* fix: cobra-cli completion

(cherry picked from commit 623f346)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants