flatten
fun <T : BaseCliktCommand<T>> CommandInvocation<T>.flatten(finalize: Boolean = true): FlatInvocations<T>
Flatten a command invocation into a sequence of invocations.
This will yield the root command invocation, followed by all subcommand invocations in the order they were invoked on the command line.
You can use this to avoid recursion when processing invocations.
Example
rootInvocation.flatten().use { invocations ->
for (invocation in invocations) {
runCommand(invocation.command)
}
}Content copied to clipboard
Parameters
finalize
If true (the default), finalize all commands as they are emitted in the sequence. If false, you must call CommandLineParser.finalizeEagerOptions and CommandLineParser.finalizeCommand on each invocation yourself before running the command.