-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add completion for flags #188
Comments
First, please format your code properly (add 4 spaces before pasting it into an issue or use sites like pastebin.org for posting big chunks of code). Have you check if bash completion works? You can do that by calling |
@VarunUmesh correct, the autocompletion only works for subcommands, not flags, as noted here: https://github.com/codegangsta/cli#bash-completion |
i think the author means that it should also work for flags since there is no reason for it not to work (at least non I can think of) Sent from my iPhone
|
Fair enough, I'll re-open as an enhancement. |
Any update on this issue? Is there a way to add completion for flags at this moment ? |
I haven't had a chance to take a stab at this yet, put PRs are welcome! |
Can someone review and merge the changes in #808 ? |
I am trying to work on the auto-completion part using this framework, and it does not work with the flags option. Here is my piece of code:
package main
import (
"fmt"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "greet"
app.Usage = "sample command-line app by greet"
app.Author = "abc"
app.Email = "xyz@aaa.com"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "read",
ShortName: "r",
Usage: "read something",
Subcommands: []cli.Command{
{
Name: "articles",
Usage: "read articles",
Action: readArticles,
},
Name: "account",
Value: "SomeThing",
Usage: "name of Twitter account",
},
},
Action: readTwitter,
},
},
},
}
app.Run(os.Args)
}
func readArticles(ctx *cli.Context) {
fmt.Println("Go to http://www.google.com to read articles!")
}
func readTwitter(ctx *cli.Context) {
fmt.Printf("Go to https://twitter.com/%s to read tweets!", ctx.String("account"))
}
When i try to do an autocomplete on the flags, it does not work. Could anybody let me know if this is supported by the framework?
Example:
./greet read tweets --a [TAB][TAB] does not work.
The text was updated successfully, but these errors were encountered: