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 arrays not rendered correctly with @{DEFAULT-VALUE} #419

Closed
remkop opened this issue Jul 22, 2018 · 1 comment
Closed
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Jul 22, 2018

@{DEFAULT-VALUE} is replaced with the array toString() which does not show the values.

The workaround is to use a List instead of an array.

@remkop remkop added this to the 3.4 milestone Jul 22, 2018
@remkop
Copy link
Owner Author

remkop commented Jul 23, 2018

Failing test

    @Test
    public void testCommandShowDefaultValuesVariableForArrayField() {
        @Command(showDefaultValues = true)
        class Params {
            @Option(names = {"-x", "--array"}, required = true, description = "null array: Default: ${DEFAULT-VALUE}")
            int[] nil;
            @Option(names = {"-y", "--other"}, required = true, description = "non-null: Default: ${DEFAULT-VALUE}")
            int[] other = {1, 5, 11, 23};
        }
        String result = usageString(new Params(), Help.Ansi.OFF);
        assertEquals(format("" +
                "Usage: <main class> -x=<nil> [-x=<nil>]... -y=<other> [-y=<other>]...%n" +
                "  -x, --array=<nil>     null array: Default: null%n" +
                "  -y, --other=<other>   non-null: Default: [1, 5, 11, 23]%n"), result);
    }

remkop added a commit that referenced this issue Jul 23, 2018
@remkop remkop closed this as completed Jul 23, 2018
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

1 participant