-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
443e67a
commit 19686f0
Showing
7 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
quarkus-picocli/src/main/java/io/quarkus/ts/qe/command/OtherCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.ts.qe.command; | ||
|
||
import io.quarkus.logging.Log; | ||
|
||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "start", description = "Starts the service.") | ||
public class OtherCommand implements Runnable { | ||
|
||
@CommandLine.Mixin | ||
CommonOptions commonOptions; | ||
|
||
@CommandLine.Option(names = { "-t", "--timeout" }, description = "Timeout in seconds", defaultValue = "60") | ||
int timeout; | ||
|
||
@Override | ||
public void run() { | ||
Log.infof("Service started with timeout: %d and verbosity: %s%n", timeout, commonOptions); | ||
} | ||
|
||
} | ||
|
||
class CommonOptions { | ||
@CommandLine.Option(names = { "-v", "--verbose" }, description = "Enable verbose mode") | ||
boolean verbose; | ||
} |
16 changes: 16 additions & 0 deletions
16
quarkus-picocli/src/main/java/io/quarkus/ts/qe/command/OtherEntryCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.ts.qe.command; | ||
|
||
import io.quarkus.logging.Log; | ||
|
||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command(name = "other", mixinStandardHelpOptions = true, subcommands = { OtherCommand.class }) | ||
public class OtherEntryCommand implements Runnable { | ||
@CommandLine.Spec | ||
CommandLine.Model.CommandSpec spec; | ||
|
||
@Override | ||
public void run() { | ||
Log.info("OtherEntryCommand with name " + spec.name()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
quarkus-picocli/src/main/java/io/quarkus/ts/qe/configuration/Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.ts.qe.configuration; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
|
||
import io.quarkus.arc.profile.IfBuildProfile; | ||
import io.quarkus.picocli.runtime.annotations.TopCommand; | ||
import io.quarkus.ts.qe.command.EntryCommand; | ||
import io.quarkus.ts.qe.command.OtherEntryCommand; | ||
|
||
@ApplicationScoped | ||
public class Config { | ||
@Produces | ||
@TopCommand | ||
@IfBuildProfile("dev") | ||
public Object devCommand() { | ||
return EntryCommand.class; | ||
} | ||
|
||
@Produces | ||
@TopCommand | ||
@IfBuildProfile("prod") | ||
public Object prodCommand() { | ||
return OtherEntryCommand.class; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.profile=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import static java.util.concurrent.CompletableFuture.runAsync; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
|
||
@Disabled ("No possible to test 2 profiles with the same build") | ||
@QuarkusScenario | ||
public class ProdiIT { | ||
@QuarkusApplication | ||
static final RestService customized = new RestService() | ||
.withProperty("quarkus.args", "start -t 60 -v") | ||
.withProperty("quarkus.profile", "prod") | ||
.setAutoStart(false); | ||
|
||
@Test | ||
public void verifyCustomizedCommandLineBehavior() { | ||
String expectedOutput = "Service started with timeout: 60 and verbosity"; | ||
try { | ||
runAsync(customized::start); | ||
customized.logs().assertContains(expectedOutput); | ||
} finally { | ||
customized.stop(); | ||
} | ||
} | ||
} |