Skip to content

Commit

Permalink
Add Picocli-based program
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed Aug 10, 2023
1 parent 883bfc5 commit 9534295
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ jobs:
- name: 'Run Java program'
shell: bash
run: java version.java
- name: 'Show help of a Java program using Picocli'
shell: bash
run: java -cp picocli-4.7.4.jar ASCIIArt.java --help
25 changes: 25 additions & 0 deletions ASCIIArt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true)
public class ASCIIArt implements Runnable {

@Option(names = { "-s", "--font-size" }, description = "Font size")
int fontSize = 19;

@Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli",
description = "Words to be translated into ASCII art.")
private String[] words = { "Hello,", "picocli" };

@Override
public void run() {
System.out.println(java.util.List.of(words));
}

public static void main(String[] args) {
int exitCode = new CommandLine(new ASCIIArt()).execute(args);
System.exit(exitCode);
}
}
Binary file added picocli-4.7.4.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion version.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class version {
public static void main(String... args) throws Exception {
System.out.println("Java " + Runtime.getRuntime().version());
System.out.println("Java " + Runtime.version());

var errors = Path.of("errors.txt");
var output = Path.of("output.txt");
Expand Down

0 comments on commit 9534295

Please sign in to comment.