-
Notifications
You must be signed in to change notification settings - Fork 425
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
allow option with a default the same as a subcommand name #1428
Comments
Hi @cbcmg, I believe this is a duplicate of #1125 Can you check if the workaround suggested in #1125 helps to alleviate the problem for you? Roughly, something like this: class PortalCmd : Callable<Int> {
@Option(
names = ["--username"],
parameterConsumer = MyParameterConsumer::class,
defaultValue = "admin",
scope = CommandLine.ScopeType.INHERIT
)
var username: String? = null
...
}
class MyParameterConsumer : IParameterConsumer {
override fun consumeParameters(args: Stack<String>, argSpec: ArgSpec, commandSpec: CommandSpec) {
if (args.isEmpty()) { // this check may be unnecessary
throw ParameterException(commandSpec.commandLine(),
"Missing required parameter for option " + ((OptionSpec) argSpec).longestName());
}
argSpec.setValue(args.pop());
}
} |
Yep, that did the trick. Sorry for my terrible search skills. And thanks for a terrific library!! |
No worries. Maybe this should be added to the documentation; I don’t see myself working on that issue in the near future… Do you feel like contributing a PR to the documentation? |
…s a default value
…mmands and default values
…on subcommands and default values" This reverts commit 9f37fb3.
…e name as a default value" This reverts commit 1449834.
…on subcommands and default values" This reverts commit 9f37fb3.
…e name as a default value" This reverts commit 1449834.
…mary": causes javascript to hang in browser while rendering the page
Hi, I would like to have an option available to all subcommands that happens to have a default value which is also the name of a subcommand. This currently fails due to the argSpec failing varargCanConsumeNextValue(). I'm not sure if this is by design or a limitation, or a bug. Here is a reproduction. Thanks
The text was updated successfully, but these errors were encountered: