Skip to content

Commit

Permalink
Example for boolean parameters with default false should be setting i…
Browse files Browse the repository at this point in the history
…t to true

Friday fun 👋😀
  • Loading branch information
timyates committed Sep 1, 2023
1 parent f661025 commit 1050e72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/gradlex/buildparameters/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void printDetails(StyledTextOutput output) {
exampleValue = "42";
} else if (parameter instanceof BooleanBuildParameter) {
type = "Boolean";
exampleValue = "false";
exampleValue = ((BooleanBuildParameter)parameter).getDefaultValue().map(v -> v ? "false" : "true").getOrElse("false");
} else if (parameter instanceof EnumBuildParameter) {
type = "Enum";
exampleValue = ((EnumBuildParameter) parameter).getValues().get().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ParametersTaskFuncTest extends Specification {
result.output.contains("Examples\n -Pdeployment.dev.port=42")
}

def "prints details for Boolean parameter"() {
def "prints details for Boolean parameter with a false default"() {
when:
def result = build(":build-logic:parameters", "--details", "ci")

Expand All @@ -131,7 +131,19 @@ class ParametersTaskFuncTest extends Specification {
!result.output.contains("Description")
result.output.contains("Default value\n false")
result.output.contains("Environment Variable\n CI")
result.output.contains("Examples\n -Pci\n -Pci=false")
result.output.contains("Examples\n -Pci\n -Pci=true")
}

def "prints details for Boolean parameter with no default"() {
when:
def result = build(":build-logic:parameters", "--details", "local")

then:
result.output.contains("Type\n Boolean")
!result.output.contains("Description")
result.output.contains("Default value\n (none)")
result.output.contains("Environment Variable\n LOCAL_RUN")
result.output.contains("Examples\n -Plocal\n -Plocal=false")
}

def "prints details for Enum parameter"() {
Expand Down

0 comments on commit 1050e72

Please sign in to comment.