You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/aesh/command-definition.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ The `@CommandDefinition` annotation is used to define a command class.
27
27
|`activator`|`Class<? extends CommandActivator>`|`NullCommandActivator.class`| Activator to check if command is available |
28
28
|`defaultValueProvider`|`Class<? extends DefaultValueProvider>`|`NullDefaultValueProvider.class`| Dynamic default value resolver |
29
29
|`stopAtFirstPositional`|`boolean`|`false`| Stop option parsing after the first positional argument |
30
+
|`sortOptions`|`boolean`|`false`| Sort help options alphabetically by name (after explicit option order) |
30
31
|`helpUrl`|`String`|`""`| URL to documentation (shown in `--help` output) |
31
32
|`helpGroup`|`String`|`""`| Group heading when listed as a subcommand in parent's help |
32
33
|`helpSectionProvider`|`Class<? extends HelpSectionProvider>`|`NullHelpSectionProvider.class`| Provider for dynamic help sections |
@@ -176,6 +177,43 @@ With the command above:
176
177
177
178
Note that `--help` (and `--version`) before the first positional still work normally when `generateHelp = true`. Only tokens after the first positional are treated as passthrough arguments.
178
179
180
+
## Option Ordering in Help
181
+
182
+
Use `sortOptions` to control how options are ordered in help output:
183
+
184
+
-`sortOptions = false` (default): options are ordered by explicit option `order`, then declaration order
185
+
-`sortOptions = true`: options are ordered by explicit option `order`, then alphabetical name
Use `order` on options to explicitly control help output order:
550
+
551
+
```java
552
+
@Option(description="Always first", order=10)
553
+
privateboolean ci;
554
+
555
+
@Option(description="Shown after --ci", order=20)
556
+
privateString profile;
557
+
```
558
+
559
+
Options are ordered by:
560
+
561
+
1.`order` (lower first)
562
+
2. Then by command-level `sortOptions` behavior:
563
+
-`sortOptions = false` (default): declaration order
564
+
-`sortOptions = true`: alphabetical by option name
565
+
566
+
`order` also works on `@OptionList` and `@OptionGroup`.
567
+
546
568
## Mutually Exclusive Options
547
569
548
570
The `exclusiveWith` property declares that two or more options cannot be used together. If a user provides both, a `MutuallyExclusiveOptionException` is thrown during parsing.
0 commit comments