diff --git a/src/main/java/com/seed4j/cli/command/infrastructure/primary/ApplyModuleSubCommand.java b/src/main/java/com/seed4j/cli/command/infrastructure/primary/ApplyModuleSubCommand.java index 1bba40c6..8982df69 100644 --- a/src/main/java/com/seed4j/cli/command/infrastructure/primary/ApplyModuleSubCommand.java +++ b/src/main/java/com/seed4j/cli/command/infrastructure/primary/ApplyModuleSubCommand.java @@ -96,8 +96,9 @@ private void addOptions(CommandSpec spec, Seed4JModulePropertiesDefinition prope spec.addOption( OptionSpec.builder(toDashedFormat(property.key())) .description( - "%s%s".formatted( + "%s%s%s".formatted( property.description().map(Seed4JPropertyDescription::get).orElse(""), + exampleValues(property), property.isMandatory() ? " (required)" : "" ) ) @@ -113,6 +114,14 @@ private List completionCandidates(Seed4JModulePropertyDefinition propert return knownCompletionCandidates.candidates(property); } + private String exampleValues(Seed4JModulePropertyDefinition property) { + List candidates = knownCompletionCandidates.candidates(property); + if (candidates.isEmpty()) { + return ""; + } + return " e.g. " + String.join(", ", candidates); + } + @ExcludeFromGeneratedCodeCoverage(reason = "There is no Seed4J module using a property with the BOOLEAN type") private static Class toOptionType(Seed4JPropertyType type) { return switch (type) { diff --git a/src/test/java/com/seed4j/cli/command/infrastructure/primary/Seed4JCommandsFactoryTest.java b/src/test/java/com/seed4j/cli/command/infrastructure/primary/Seed4JCommandsFactoryTest.java index 06d20070..83a3ff4e 100644 --- a/src/test/java/com/seed4j/cli/command/infrastructure/primary/Seed4JCommandsFactoryTest.java +++ b/src/test/java/com/seed4j/cli/command/infrastructure/primary/Seed4JCommandsFactoryTest.java @@ -516,8 +516,25 @@ void shouldNotApplyInitModuleMissingRequiredOptions(CapturedOutput output) throw .contains("Missing required") .contains("'--base-name='") .contains("'--project-name='") - .contains("Project short name (only letters and numbers) (required)") - .contains("Project full name (required)"); + .contains("Project short name (only letters and numbers) e.g.") + .contains("seed4jSampleApplication (required)") + .contains("Project full name e.g. Seed4J Sample Application") + .contains("(required)"); + } + + @Test + void shouldShowExampleValuesInHelpDescription(CapturedOutput output) { + String[] args = { "apply", "init", "--help" }; + + int exitCode = commandLine(modules, projects).execute(args); + + assertThat(exitCode).isZero(); + assertThat(output) + .contains("Project short name (only letters and numbers) e.g.") + .contains("seed4jSampleApplication (required)") + .contains("Node package manager e.g. npm, pnpm (required)") + .contains("Project full name e.g. Seed4J Sample Application") + .contains("(required)"); } @Test