Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created June 9, 2022 21:35
Show Gist options
  • Save maxandersen/74ea3a5ead0f679c08b5ca748f5db32b to your computer and use it in GitHub Desktop.
Save maxandersen/74ea3a5ead0f679c08b5ca748f5db32b to your computer and use it in GitHub Desktop.
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
//SOURCES hello.java
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;
@Command(name = "hello", mixinStandardHelpOptions = true, version = "hello 0.1",
description = "hello made with jbang")
class hello 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 hello()).execute(args);
System.exit(exitCode);
}
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Hello " + greeting);
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment