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

Flags in commands #54

Closed
marksteve opened this issue Dec 11, 2013 · 6 comments
Closed

Flags in commands #54

marksteve opened this issue Dec 11, 2013 · 6 comments
Labels
kind/bug describes or fixes a bug

Comments

@marksteve
Copy link

app.Commands = []cli.Command{
  {
    Name: "command",
    Action: func(c *cli.Context) {
      println("command")
    },
  },
}

I expected appending --help with only show usage but:

$ ./app command --help
Usage of command:
command
@marksteve
Copy link
Author

Oops. It was the flag library that was doing it. Not cli's fault.

@marksteve
Copy link
Author

Oh. I've been up for too long. It is an issue. Flags aren't working properly with commands:

package main

import (
    "os"

    "github.com/codegangsta/cli"
)

func main() {
    app := cli.NewApp()
    app.Name = "app"
    app.Commands = []cli.Command{
        {
            Name: "command",
            Action: func(c *cli.Context) {
                println("command")
            },
            Flags: []cli.Flag{
                cli.BoolFlag{"flag,f", "just a flag"},
            },
        },
    }
    app.Run(os.Args)
}

Running this produces:

$ ./app command --flag
flag provided but not defined: -flag
Usage of command:
  -flag,f=false: just a flag
command

@marksteve marksteve reopened this Dec 11, 2013
@codegangsta
Copy link
Contributor

hm. this does seem like a bug. I will look into it soon

@codegangsta
Copy link
Contributor

@marksteve I am not able to reproduce this on latest master of cli. By the look of that output it looks like you are running an older version that doesn't support the "flag,f" support

@marksteve
Copy link
Author

Did a go get -u and yeah it works now. Sorry about that. I was sure that it was my first time go get-ting the library but apparently I did before. Thanks for checking it out 😄

@codegangsta
Copy link
Contributor

No problem!

On Wed, Dec 11, 2013 at 6:36 PM, Mark Steve Samson <notifications@github.com

wrote:

Did a go get -u and yeah it works now. Sorry about that. I was sure that
it was my first time go get-ting the library but apparently I did before.
Thanks for checking it out [image: 😄]


Reply to this email directly or view it on GitHubhttps://github.com//issues/54#issuecomment-30384846
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug describes or fixes a bug
Projects
None yet
Development

No branches or pull requests

2 participants