-
hi all
i need the default value of out (in case not explixitly given), to be the caluculated value of in (either in's exlicit given value or its default value) |
Beta Was this translation helpful? Give feedback.
Answered by
remkop
Jul 25, 2023
Replies: 1 comment 1 reply
-
I haven't tried this, but one idea is to have a custom default provider, something like this: @Command(defaultValueProvider = MyDefaultProvider.class)
class MyCommand {
@Option(names = { "-in" }, description = "number of inputs. defaults to 1", defaultValue = "1")
private int in;
@Option(names = { "-out" }, description = "number of outputs. should default to inputChannelCount value")
private int out;
}
class MyDefaultProvider implements IDefaultValueProvider {
public String defaultValue(ArgSpec argSpec) {
if (argSpec.isOption() && ((OptionSpec) argSpec).longestName().equals("-out")) {
return argSpec.command().findOption("-in").getValue().toString();
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
guykatz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't tried this, but one idea is to have a custom default provider, something like this: