class Subcommand : CliktCommand()
{
private val arg by argument().optional()
private val opt by option()
override fun run() = Unit
}
class Parent : CliktCommand(allowMultipleSubcommands = true)
{
private val args: List<String> by argument("arguments").multiple()
override fun run() = Unit
init
{
this.subcommands(Subcommand())
}
}
in the command line: $ .\tool parent subcommand --opt foo subcommand bar
I get this error:
Error: got unexpected extra argument (bar)
This is, I think, incorrect and it should instead pass bar as the argument.
Note that this only happens when an option is used in the subcommand before using the argument in the next subcommand.
Running: $ .\tool parent subcommand foo subcommand bar works fine and: $ .\tool parent subcommand --opt foo subcommand --opt bar works fine too.
The issue
When running the
parent
command with this setup:in the command line:
$ .\tool parent subcommand --opt foo subcommand bar
I get this error:This is, I think, incorrect and it should instead pass
bar
as the argument.Note that this only happens when an option is used in the subcommand before using the argument in the next subcommand. Running:
$ .\tool parent subcommand foo subcommand bar
works fine and:$ .\tool parent subcommand --opt foo subcommand --opt bar
works fine too.