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

Default value for options #233

Closed
IRus opened this issue Jun 25, 2018 · 5 comments
Closed

Default value for options #233

IRus opened this issue Jun 25, 2018 · 5 comments
Assignees
Labels
Milestone

Comments

@IRus
Copy link
Contributor

IRus commented Jun 25, 2018

For example I define simple command with default value for command option:

class TestCommandDefaultOption extends CommandWithMetadata {
    public final static String OPT = "opt";

    public TestCommandDefaultOption() {
        super(CommandMetadata.builder("testCommandDefaultOption")
                .addOption(OptionMetadata.builder(OPT).defaultValue("optValue").build()));
    }

    @Override
    public CommandOutcome run(Cli cli) {
        return CommandOutcome.succeeded();
    }
}

I expecting that if I'm not pass any value for option opt I will get optValue for cli.optionString call, but instead I got null.

@IRus IRus added this to the 0.26 milestone Jun 25, 2018
@IRus
Copy link
Contributor Author

IRus commented Jun 25, 2018

Test case available in https://github.com/bootique/bootique/tree/issue-233

@IRus
Copy link
Contributor Author

IRus commented Jun 25, 2018

@andrus Is it actually bug?

@andrus
Copy link
Contributor

andrus commented Jun 26, 2018

Seems like a bug. @elena-bondareva could you check this one out?

@elena-bondareva
Copy link
Contributor

Yes, this is a bug.

elena-bondareva added a commit to elena-bondareva/bootique that referenced this issue Jul 10, 2018
elena-bondareva added a commit to elena-bondareva/bootique that referenced this issue Jul 10, 2018
stariy95 added a commit that referenced this issue Nov 28, 2018
@stariy95
Copy link
Member

Here is small bug overview for the history. Default value in OptionMetadata was used only as configPath default and nowhere else.
Fix changes this behavior and now default value used as stated, i.e. as default value when option is present but no value provided for that option.

@stariy95 stariy95 changed the title Default value for command options Default value for options Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants