initial jbang example

This commit is contained in:
Max Rydahl Andersen
2021-11-14 11:47:06 +01:00
parent 58e95b3c40
commit 48be3e092a
5 changed files with 92 additions and 0 deletions

27
jbang/hellocli.java Executable file
View File

@@ -0,0 +1,27 @@
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;
@Command(name = "hellocli", mixinStandardHelpOptions = true, version = "hellocli 0.1",
description = "hellocli made with jbang")
class hellocli implements Callable<Integer> {
@Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
private String greeting;
public static void main(String... args) {
int exitCode = new CommandLine(new hellocli()).execute(args);
System.exit(exitCode);
}
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Hello " + greeting);
return 0;
}
}