Skip to content

Instantly share code, notes, and snippets.

@dmi3coder
Created April 26, 2020 12:04
Show Gist options
  • Save dmi3coder/87218f5396bf5503c18eb231bb3dace9 to your computer and use it in GitHub Desktop.
Save dmi3coder/87218f5396bf5503c18eb231bb3dace9 to your computer and use it in GitHub Desktop.
Example of GreetingApplication with Picocli in Quarkus
package org.acme.getting.started;
import io.quarkus.runtime.*;
import io.quarkus.runtime.annotations.QuarkusMain;
import org.acme.getting.started.command.*;
import org.apache.maven.shared.utils.cli.CommandLineUtils;
import picocli.CommandLine;
import javax.inject.Inject;
@QuarkusMain
public class GreetingApplication implements QuarkusApplication {
@Inject
GreetingCommand greetingCommand;
@Override
public int run(String... args) throws Exception {
if (args.length == 0) {
Quarkus.waitForExit();
return 0;
}
if (args.length == 1) {
args = CommandLineUtils.translateCommandline(args[0]);
}
return new CommandLine(new QuarkusCommand())
.addSubcommand(greetingCommand)
.execute(args);
}
public static void main(String[] args) {
Quarkus.run(GreetingApplication.class, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment