-
Notifications
You must be signed in to change notification settings - Fork 27
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
zsh completion doesn't work #121
Comments
Weird. This should enable the competition part based on the official urfave/cli docs. It has zsh support and I comp file is coming from there repo. I just replaced the |
I checked if we are using the latest version of now and maybe it was fixed in the library, but we have the latest I don't think I can do more than that sadly. |
Hello @yitsushi , E.g. if you try the bash completion, this happens:
It basically brings up the help/error message and tries to parse the help text in completable commands, which obviously doesn't work. Are you sure your implementation is complete? Taking a look at https://github.com/yitsushi/totp-cli/blob/main/app.go, it seems that you're missing blocks like these (as described in https://cli.urfave.org/v2/examples/bash-completions/)
Also the parameter At least it's mentioned in: |
No they are there but behind the functions Commands: []*cli.Command{
cmd.AddTokenCommand(),
// ...
} and That's the same as having it inline. I have all the fields on it: https://github.com/yitsushi/totp-cli/blob/main/internal/cmd/add_token.go#L14 I just didn't create one big array, I build it up from chunks, but the end result is the same, this gets into the
As the documentation says, enabling that flag should add For the bash stuff. Yes because bash parses the output no matter what it is, it prints out the help because |
I have a feeling when a refactor happened there, they removed the part that adds the flag to the command. Based on this search: https://github.com/search?q=repo%3Aurfave%2Fcli%20GenerateShellCompletionFlag&type=code
|
Ok sorry, I didn't want to confuse you, my programming skills are rather barebones and I didn't notice the include. But it would definitely be nice to have it working again, if a recent dependency update broke it maybe an earlier version of |
I'll try to add the flag manually, I think the flag handling is still there, but the flag set is missing. I think if I add the flag on my side, the core will handle it. If not, I'll try to check when it was removed and either open a PR there to add it back or just revert to older version of Looking at the work done there in the last 6-8 months, it seems |
and just to be fair, I never used autocomplete so I just hoped it's working, others fixed it, added extras with PRs, but as by scope it can only autocomplete commands and flags, and it can't autocomplete namespaces and token names because that's encrypted and only decrypted when a specific command was issued. |
Well, half success 🤣
If I add the flag it kinda like it, but for some reasons it cuts off on what, it does for all flags 😱 :
|
It seems it's not even my side. I created a new app in an empty directory, copy paste the first example from https://cli.urfave.org/v2/examples/flags/. It's funny it recognises the flag |
As a quick research, I don't know how to fix it now. I checked what version I used when I moved away from my own old cli lib: Created a demo app: module asd
go 1.22.2
require github.com/urfave/cli/v2 v2.25.7
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
) and the go file: package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
EnableBashCompletion: true,
Commands: []*cli.Command{
{
Name: "add",
Aliases: []string{"a"},
Usage: "add a task to the list",
Action: func(cCtx *cli.Context) error {
fmt.Println("added task: ", cCtx.Args().First())
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
} as a result:
I don't know if it every worked or not at this point. |
Thanks for your work on
totp-cli
, very much appreciated!I noticed that the zsh completion doesn't work. It seems it's trying to evaluate the cli options by calling
--generate-shell-completion
, however this command doesn't exist. Is there an updated version, or another way to generate the completion file?File taken from:
version:
The text was updated successfully, but these errors were encountered: