Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)" : ""
)
)
Expand All @@ -113,6 +114,14 @@ private List<String> completionCandidates(Seed4JModulePropertyDefinition propert
return knownCompletionCandidates.candidates(property);
}

private String exampleValues(Seed4JModulePropertyDefinition property) {
List<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,25 @@ void shouldNotApplyInitModuleMissingRequiredOptions(CapturedOutput output) throw
.contains("Missing required")
.contains("'--base-name=<basename*>'")
.contains("'--project-name=<projectname*>'")
.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
Expand Down
Loading