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

panic on addArg failure, and tests to check it #57

Merged
merged 1 commit into from Jan 21, 2020

Conversation

goofinator
Copy link
Contributor

@goofinator goofinator commented Jan 19, 2020

Is something like this normal to test addArg success?

By the way: after adding this check, 2 errors occurred in the test functions.
1 - no long name, while Case sensitivity was tested.
2 - short name "i1".

@@ -441,7 +501,7 @@ func TestFailCaseSensitive(t *testing.T) {
testArgs := []string{"progname", "-F"}

p := NewParser("", "description")
_ = p.Flag("f", "", &Options{Required: true})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tries to test case sensitivity, but actually - the undefined argument check because of silent argument drop

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I remember long name should be required one and short name is optional. that should be in godoc or in readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. And here only a shortened argument was provided.

@@ -1362,7 +1684,7 @@ func TestUsageHidden1(t *testing.T) {
_ = cmd1.Flag("a", "verylongflagA", &Options{Required: true, Help: "flag1 description"})
_ = p.String("s", "verylongstring-flag1", &Options{Help: "string1 description"})
_ = p.Int("i", "integer-flag1", &Options{Help: "integer1 description"})
_ = p.Int("i2", "integer-flag2", &Options{Help: DisableDescription})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description disabled because of "i2" - long shorthand argument and silent drop of argument, not because of DisableDescription.

@akamensky
Copy link
Owner

LGTM

@akamensky akamensky merged commit 48862cb into akamensky:master Jan 21, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants