Created
June 9, 2022 21:35
-
-
Save maxandersen/74ea3a5ead0f679c08b5ca748f5db32b to your computer and use it in GitHub Desktop.
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
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS info.picocli:picocli:4.5.0 | |
//SOURCES hello.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
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