Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add completion for flags #188

@VarunUmesh

Description

@VarunUmesh

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"

"github.com/codegangsta/cli"

)

func main() {
app := cli.NewApp()
app.Name = "greet"
app.Usage = "sample command-line app by greet"
app.Author = "abc"
app.Email = "[email protected]"
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:   "tweets",
                    Usage:  "read Tweets",
                    Flags: []cli.Flag{
                            cli.StringFlag{

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedplease help if you can!kind/featuredescribes a code enhancement / feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions