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

-vvv looks broken #52

Closed
fenollp opened this issue Jan 19, 2018 · 2 comments
Closed

-vvv looks broken #52

fenollp opened this issue Jan 19, 2018 · 2 comments

Comments

@fenollp
Copy link

fenollp commented Jan 19, 2018

Hi. After the merge of the big rewrite about a week ago it seems that [-vvv] handling is broken.
Before, something along

Options:
  mybin [-vvv] act

With args[“-v”].(int) would take values from 0 to 3 for the inputs:

  • mybin act
  • mybin -v act
  • mybin -vv act
  • mybin -vvv act

Now with the new parser and the new API args.Int(“-v”) gives a value of 0 and an error along the lines of “this is uncastable” for any amount of Vs.

I will work on creating a minimal example that uses both APIs tomorrow. I don’t remember that I found this usage in the golang examples/tests.

But then I am maybe just misusing the newer api. What do you think?
cc @aviddiviner

@fenollp
Copy link
Author

fenollp commented Jan 19, 2018

Note: this is saying that #36 was half solved, at least before the rewrite.

@fenollp
Copy link
Author

fenollp commented Jan 19, 2018

Ah!
args.Int("-v") failed with key: "-v" failed type conversion because it's already an int!
Solved it by just using args["-v"].(int).

Maybe opts.go Int,Float64 funcs could have a case that checks reflect.TypeOf before attempting strconv? I can make that PR if you'd like.

Anyhow, this is more of feature request than a bugfix. Issue solved.

@fenollp fenollp closed this as completed Jan 19, 2018
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

1 participant