-
Notifications
You must be signed in to change notification settings - Fork 879
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
Fix potential bug in Env default value provider #644
Conversation
-- Bypass default value for positional parameter. In case of subcommands such as help this could have thrown class cast exception Signed-off-by: Usman Saleem <usman@usmans.info>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a test case covering the control flow / highlighting the bug?
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
Signed-off-by: Usman Saleem <usman@usmans.info>
@@ -36,6 +36,10 @@ public EnvironmentVariableDefaultProvider(final Map<String, String> environment) | |||
|
|||
@Override | |||
public String defaultValue(final ArgSpec argSpec) { | |||
if (!argSpec.isOption()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning for using the negation of isOption()
instead of simply using isPositional()
to identify a positional param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point ... I think I saw an example which was using isOption
which stuck in my head, i didn't realised about isPositional. I'll change it to use isPositional. 👍
Signed-off-by: Usman Saleem <usman@usmans.info>
Bypass default value from environment variable provider for positional parameter. In case of subcommands such as help this could have thrown class cast exception
Signed-off-by: Usman Saleem usman@usmans.info