From f6f8d93fff15d3b70cc437760e5ce4db4b98344f Mon Sep 17 00:00:00 2001 From: Marko Mackic Date: Sun, 17 Oct 2021 21:33:45 +0200 Subject: [PATCH] Revert "[#1428] DOC: make a note about subcommands with the same name as a default value" This reverts commit 1449834408deeac6b1dd88cfb599823015d072b8. --- docs/index.adoc | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/docs/index.adoc b/docs/index.adoc index b92fd6dd7..ae5650982 100644 --- a/docs/index.adoc +++ b/docs/index.adoc @@ -8595,31 +8595,6 @@ class Git : Runnable { By default, the synopsis of a command with subcommands shows a trailing `[COMMAND]`, indicating that a subcommand can optionally be specified. To show that the subcommand is mandatory, use the `synopsisSubcommandLabel` attribute to replace this string with `COMMAND` (without the `[` and `]` brackets). -=== Subcommands and default values - -There are some scenarios where picocli can not parse an option with a default value which is the same as a subcommand name. To work around this, you can parse the option yourself using <>. A simple implementation is shown below. See https://github.com/remkop/picocli/issues/1428[this issue] for more details. - - -.Kotlin -[source,kotlin,role="secondary"] ----- -class MyParameterConsumer : CommandLine.IParameterConsumer { - override fun consumeParameters( - args: Stack, - argSpec: CommandLine.Model.ArgSpec, - commandSpec: CommandLine.Model.CommandSpec - ) { - if (args.isEmpty()) { - throw CommandLine.ParameterException( - commandSpec.commandLine(), - "Missing required parameter for option " + - (argSpec as CommandLine.Model.OptionSpec).longestName() - ) - } - argSpec.setValue(args.pop()); - } -} ----- == Reuse You may find yourself defining the same options, parameters or command attributes in many command line applications.