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

Option "mapFallbackValue" ignored when inherited to subcommand #2035

Closed
zman0900 opened this issue Jun 1, 2023 · 2 comments · Fixed by #2036
Closed

Option "mapFallbackValue" ignored when inherited to subcommand #2035

zman0900 opened this issue Jun 1, 2023 · 2 comments · Fixed by #2036
Milestone

Comments

@zman0900
Copy link

zman0900 commented Jun 1, 2023

With an @option defined like this:

@Command(
    name = "main"
    subcommands = {
        SubCmd.class,
        CommandLine.HelpCommand.class
    }
)
public class Main {
    @Option(
            names = "-D",
            paramLabel = "<key=value>",
            mapFallbackValue = Option.NULL_VALUE,
            scope = ScopeType.INHERIT
    )
    private final Map<String, String> javaOpts = new HashMap<>();
}

@Command(name = "sub")
public class SubCmd {
    @ParentCommand
    private Main parent;
}

Running with args like ["sub", "-Dxyz"] results in error message:

Value for option option '-D' (<key=value>) should be in KEY=VALUE format but was xyz

This seems like it might be because the ArgSpec Builder copy constructor doesn't copy the "mapFallbackValue" field in picocli 4.7.3: https://github.com/remkop/picocli/blob/v4.7.3/src/main/java/picocli/CommandLine.java#L9496

@remkop
Copy link
Owner

remkop commented Jun 1, 2023

Thank you for raising this, and thank you for the analysis!
It’s very plausible that that’s the cause.

Will you be able to provide a pull request for this?

@zman0900
Copy link
Author

zman0900 commented Jun 1, 2023

PR #2036 opened

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

Successfully merging a pull request may close this issue.

2 participants