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

Variable interpolation in defaultValue are not expanded in standard help #723

Closed
mbarbero opened this issue Jun 10, 2019 · 6 comments
Closed

Comments

@mbarbero
Copy link

When using an option with defaultValue=${sys:user.home}, the field value is properly set. However, when using standard help options mixin, the help string mentions "Default: ${sys:user.home}" while I think it should display the interpolated value.

@mbarbero mbarbero changed the title Variable interpolation in defaultValue are not expanded in standard help option Variable interpolation in defaultValue are not expanded in standard help Jun 10, 2019
@remkop
Copy link
Owner

remkop commented Jun 10, 2019

That sounds like a bug. Can you paste some example code to help me reproduce the issue?

@remkop
Copy link
Owner

remkop commented Jun 11, 2019

I've been able to reproduce the issue with this test:

@Test
public void testIssue723() {
    @Command(mixinStandardHelpOptions = false, showDefaultValues = true)
    class Issue723 {
        @Option(names="--mypath", defaultValue = "${sys:user.home}",
                description = "Path. Default=${DEFAULT-VALUE}.")
        private String path;
    }
    String expected = String.format("" +
            "Usage: <main class> [--mypath=<path>]%n" +
            "      --mypath=<path>   Path. Default=%1$s.%n" +
            "                          Default: %1$s%n",
            System.getProperty("user.home"));

    String actual = new CommandLine(new Issue723()).getUsageMessage(CommandLine.Help.Ansi.OFF);
    assertEquals(expected, actual);
}

This currently prints:

Usage: <main class> [--mypath=<path>]
      --mypath=<path>   Path. Default=C:\Users\remko.
                          Default: ${sys:user.home}

If your issue is different, please let me know. I am investigating the above now.

@remkop remkop closed this as completed in 292719c Jun 11, 2019
@remkop
Copy link
Owner

remkop commented Jun 11, 2019

Fixed in master. Can you verify?

@remkop remkop added this to the 4.0 milestone Jun 11, 2019
@mbarbero
Copy link
Author

Verified. Thanks for the quick turnaround and the good work on this project!

@remkop
Copy link
Owner

remkop commented Jun 11, 2019

Thanks for the verification.
Please star the project on GitHub if you like it! 😉

@remkop remkop modified the milestones: 4.0, 4.0-beta-2 Jun 18, 2019
@remkop
Copy link
Owner

remkop commented Jun 19, 2019

FYI, 4.0.0-beta-2 has been released. It may take a few hours for Maven mirrors to update.
Thanks again for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants