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

Help displays false default values #143

Closed
eproxus opened this issue Jul 14, 2015 · 2 comments
Closed

Help displays false default values #143

eproxus opened this issue Jul 14, 2015 · 2 comments

Comments

@eproxus
Copy link

eproxus commented Jul 14, 2015

Given a option with no default value:

package main

import "github.com/jessevdk/go-flags"

type opts struct {
    Value int `short:"v" description:"The value"`
}

func main() {
    var opts opts
    flags.Parse(&opts)
}

Calling help with that option set will display a false default value:

$ go run main.go -v 7 -h
Usage:
  main [OPTIONS]

Application Options:
  -v=         The value (7)

Help Options:
  -h, --help  Show this help message

This can lead to mistakes where users think there is a default value where there is none.

@jessevdk
Copy link
Owner

The original reason for this was to cover this case:

opts := struct {
    Value int `short:"v" description:"The value"`
} {
    Value: 5
}

flags.Parse(&opts)

So the initial value would really be the current value. That said, it obviously doesn't work for your case.

@eproxus
Copy link
Author

eproxus commented Oct 12, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants