Skip to content

Commit 1ff8aaf

Browse files
committed
Document auto enum values in option help output (#491)
Add 'Enum Options and Valid Values' section to options.md explaining that enum options automatically append 'Valid values: x, y, z' to help descriptions, with examples showing the auto-append and the deduplication when ${COMPLETION-CANDIDATES} is already used.
1 parent 5420bfe commit 1ff8aaf

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎content/docs/aesh/options.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,37 @@ Text blocks (Java 15+) also work — leading indentation is automatically stripp
14021402
String environment;
14031403
```
14041404

1405+
## Enum Options and Valid Values
1406+
1407+
When an option uses an enum type, aesh automatically appends the valid values to the help description. You don't need to manually list them -- they stay in sync with the actual enum constants.
1408+
1409+
```java
1410+
public enum Format { TEXT, JSON, XML }
1411+
1412+
@Option(name = "format", description = "Output format")
1413+
Format format;
1414+
```
1415+
1416+
Help output:
1417+
```
1418+
--format=<format> Output format. Valid values: text, json, xml
1419+
```
1420+
1421+
If you add a new value to the enum, the help updates automatically.
1422+
1423+
The auto-append is skipped when the description already contains the values (e.g., via `${COMPLETION-CANDIDATES}`), so there is no duplication:
1424+
1425+
```java
1426+
@Option(name = "format", description = "Output format (${COMPLETION-CANDIDATES})")
1427+
Format format;
1428+
// Renders: --format=<format> Output format (text, json, xml)
1429+
// "Valid values:" is NOT appended since the values are already shown
1430+
```
1431+
1432+
{{< callout type="info" >}}
1433+
Enum values are shown in lowercase in help output. The parser accepts values case-insensitively (e.g., `--format TEXT`, `--format text`, and `--format Text` all work).
1434+
{{< /callout >}}
1435+
14051436
## Description Variables
14061437

14071438
Option and command descriptions support `${VARIABLE}` placeholders that are resolved at help-render time. This keeps descriptions in sync with annotation values automatically.

0 commit comments

Comments
 (0)