-
Notifications
You must be signed in to change notification settings - Fork 129
Open
Description
If I am not mistaken, there is currently no way of adding a ChainedCliktCommand as a subcommand of a "regular" CliktCommand.
For example the following wouldn't compile:
class R1: CliktCommand(){ override fun run() = TODO() }
class R2: CliktCommand(){ override fun run() = TODO() }
class R3: CliktCommand(){ override fun run() = TODO() }
class C1: ChainedCliktCommand<Int>(){ override fun run(value: Int): Int { TODO() } }
class C2: ChainedCliktCommand<Int>(){ override fun run(value: Int): Int { TODO() } }
class C3: ChainedCliktCommand<Int>(){ override fun run(value: Int): Int { TODO() } }
fun test(){
R1().subcommands(
R2().subcommands( //type incompatible!
C1().subcommands(
C2(),
C3(),
)
),
R3()
)
}The existing behavior kind of makes sense because chained commands requires an initial value to "kick things off" in the main function call, while regular commands doesn't.
However in some cases the initial value provided to a chained command could simply be a constant, like in my case where I'm performing some kind of folding/reduction operation.
It would be nice if we could do something like:
R1().subcommands(
R2().subcommands(
C1().subcommands(
C2(),
C3(),
).initial(12345) //function that converts chained command to regular command
),
R3()
)Thanks!
Metadata
Metadata
Assignees
Labels
No labels