integrii / flaggy

Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.
The Unlicense
856 stars 30 forks source link

[WIP] Fix handling of 'ShowHelpOnUnexpected' option #54

Closed ravenpride closed 4 years ago

ravenpride commented 4 years ago

This PR is a fix for issue #47.

ravenpride commented 4 years ago

Although it works for me, one of your unit tests (TestDoubleParse) fails now. Running this test within VS Code passes. Could you please have a look at it?

ravenpride commented 4 years ago

Ok, the last change should handle trailing arguments better, but the test issue persists. I've debugged it and found out that the test runner itself passes command line arguments to the test application. These arguments do not pass the new validation step, of course. Would it be ok for you to add a test specific workaround for this case, e.g. pruning arguments that start with test. from the argument list?

ravenpride commented 4 years ago

Ok, that one looks better and all unit test pass. For two unit tests, I had to clear the argument list. In my opinion, this PR is ready to merge - after your approval, of course :-)

ravenpride commented 4 years ago

After playing around with it some more, it seems that the fix works for global flags, but fails for subcommand flags. The issue is trickier than it first looked :-/ Ergo, not ready to merge - but it would be great, if you could share your thoughts with me about this issue. This could help me to fix it.

integrii commented 4 years ago

Potentially we could do #55 here instead of this one

ravenpride commented 4 years ago

Looks great. I'll close this PR.