Skip to content

Commit cf0acbf

Browse files
marinierremkop
authored andcommitted
Added section Subcommand aliases section
1 parent 5391c3b commit cf0acbf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/index.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,19 @@ Custom type converters registered on a `CommandLine` instance will apply to all
19271927

19281928
Subcommands referenced in a `subcommands` attribute need to have a public no-argument constructor to be instantiated, unless a <<Custom Factory>> is installed to instantiate classes.
19291929

1930+
=== Subcommand Aliases
1931+
Commands may optionally define an `aliases` attribute to provide alternate names for commands that will be recognized by the parser. Aliases are displayed in the default help output. For example:
1932+
[source,java]
1933+
----
1934+
@Command(name = "status", aliases = {"st"}, description = "Show the working tree status.")
1935+
class GitStatus { ... }
1936+
----
1937+
1938+
Would result in this help fragment:
1939+
1940+
----
1941+
status, st Show the working tree status.
1942+
----
19301943
=== Subcommands as Methods
19311944
From picocli 3.6 it is possible to register subcommands in a very compact manner by having a `@Command` class with `@Command`-annotated methods. The methods are automatically <<Subcommand Methods, registered as subcommands>> of the `@Command` class.
19321945

0 commit comments

Comments
 (0)