You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I really like how easily complete allows to add completion to CLI tools using flag but since I use it, I have lost the classic bash completion on filenames for positional arguments.
Take this example:
package main
import (
"flag""fmt""os""github.com/posener/complete/v2"
)
funcmain() {
printJSON:=flag.Bool("json", false, "prints the filename in JSON")
complete.CommandLine()
flag.Parse()
ifflag.NArg() <1 {
fmt.Printf("File argument is missing\n\n")
flag.Usage()
os.Exit(1)
}
if*printJSON {
fmt.Println("{\"filename\": \""+flag.Arg(0) +"\"}")
} else {
fmt.Println("File: "+flag.Arg(0))
}
}
Without the complete.CommandLine() line, I do not get completion for the -json flag but my positional argument is well completed by bash.
But with this line, I do not get completion anymore.
Is there anything to get the file completion behavior back?
Thank you
The text was updated successfully, but these errors were encountered:
Hi, I really like how easily
complete
allows to add completion to CLI tools usingflag
but since I use it, I have lost the classic bash completion on filenames for positional arguments.Take this example:
Without the
complete.CommandLine()
line, I do not get completion for the-json
flag but my positional argument is well completed by bash.But with this line, I do not get completion anymore.
Is there anything to get the file completion behavior back?
Thank you
The text was updated successfully, but these errors were encountered: