Daniel
04/27/2023, 7:53 AMfun main(args: Array<String>) = Launcher.subcommands(InitKeystore).main(args)
object Launcher : CliktCommand(help = "", invokeWithoutSubcommand = true) {
...
override fun run() {
...
log("I have done something")
}
}
object InitKeystore : CliktCommand(name = "keystore_init", help = "") {
...
override fun run() {
...
log("I have done init")
}
}
When I run it without the keystore_init
subcommand, it launches correctly only the Launcher
, but when I specify the keystore_init
subcommand, I see in my output both the log strings, ie. it runs the main command and then the subcommand ?Phil Richardson
04/27/2023, 8:35 AMinvokeWithoutSubcommand
option only controls what should happen if you Do Not invoke a sub-command, i.e. only when you do not run keystore_init
in your case.
By default this is false
, meaning without a sub-command the parent is not run. When true
, the parent is run with or without a sub-command.Daniel
04/27/2023, 8:51 AMif (currentContext.invokedSubcommand == null)
appropriate solution to this?