-
Hi, I have a use case where I have 2 commands with each their own set of settings:
And I am trying to create a 3rd command that computes a diff of the other 2. As you can see above, though there is overlap in the options of the 2 commands and so I'm looking for a MixinWithPrefix capability so that I can do something like this:
And then this will define a new command where the user can do:
To add an additional constraint for context, Command1 and Command2 live in different libraries from the differ and so I can't simply arrange for the names to be distinct as they are not necessarily owned by me. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You may be able to use variable interpolation and resource bundles to give options in one command a different name than in another command. @Option(names = "${lookupkey.foo:---foo") // yes 3 dashes, that is not a typo, the ":-" means "what follows is the default"
private String foo;
@Option(names = "${lookupkey.bar:---bar")
private String bar; Then, in your diff application, you add a resource bundle that provides the option name. In the resource bundle, you prefix the |
Beta Was this translation helpful? Give feedback.
-
I'm not sure the proposed solution fixed my particular use case. I'd like a mixin that allows specifying a few flags for outputting spreadsheet-like information. One flag is needed for the CSV output location and another is needed for the XSLT location. The same command has multiple spreadsheets being output. e.g. process-results --input /foo/bar.pbbin --output_costs_csv costs.csv --output_costs_google_sheet "https://docs.google.com/spreadsheets/d/dlfkasdlnkldsanlkfasdlkj" --output_stats_csv /tmp/stats.csv If we could change a variable per-mixin-instance, the above would work. But it seems all the mixins used by a command would share the same set of variables. |
Beta Was this translation helpful? Give feedback.
You may be able to use variable interpolation and resource bundles to give options in one command a different name than in another command.
The options need to be defined something like this:
Then, in your diff application, you add a resource bundle that provides the option name.
See this example: https://picocli.info/#_shared_resource_bundles
In the resource bundle, you prefix the
lookupkey.foo
with the command name so you can have separate values for each command.