From 47919e486916c16bbf755122ac2f131075ff4289 Mon Sep 17 00:00:00 2001 From: Shelby Holden Date: Wed, 21 Jun 2023 09:33:26 -0400 Subject: [PATCH] Hello world CLI --- java-pfb-cli/README.md | 6 ++++ java-pfb-cli/build.gradle | 30 +++++++++++++++++++ .../src/main/java/JavaPfbCommand.java | 20 +++++++++++++ settings.gradle | 2 ++ 4 files changed, 58 insertions(+) create mode 100644 java-pfb-cli/README.md create mode 100644 java-pfb-cli/build.gradle create mode 100644 java-pfb-cli/src/main/java/JavaPfbCommand.java diff --git a/java-pfb-cli/README.md b/java-pfb-cli/README.md new file mode 100644 index 00000000..b66dd36f --- /dev/null +++ b/java-pfb-cli/README.md @@ -0,0 +1,6 @@ +Current usage of CLI: +First, run "fatJar" gradle task in java-pfb-cli + +Then, you can use the CLI with the following command: +java -cp "java-pfb-cli/build/libs/java-pfb-cli.jar" JavaPfbCommand +Only command right now: "hello" \ No newline at end of file diff --git a/java-pfb-cli/build.gradle b/java-pfb-cli/build.gradle new file mode 100644 index 00000000..904e44b0 --- /dev/null +++ b/java-pfb-cli/build.gradle @@ -0,0 +1,30 @@ +plugins { + id 'java' +} + +version 'unspecified' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + implementation 'info.picocli:picocli:4.7.4' +} + +task fatJar(type: Jar) { + manifest { + attributes 'Main-Class': "JavaPfbCommand" + } + archiveBaseName.set('java-pfb-cli') + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/java-pfb-cli/src/main/java/JavaPfbCommand.java b/java-pfb-cli/src/main/java/JavaPfbCommand.java new file mode 100644 index 00000000..8f25be37 --- /dev/null +++ b/java-pfb-cli/src/main/java/JavaPfbCommand.java @@ -0,0 +1,20 @@ +import picocli.CommandLine; + +import static picocli.CommandLine.Command; + +@Command(name = "pfb") +public class JavaPfbCommand implements Runnable { + public static void main(String[] args) { + CommandLine.run(new JavaPfbCommand(), args); + } + + @Override + public void run() { + System.out.println("A java implementation of pyPFB"); + } + + @Command(name = "hello") + public void helloCommand() { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index a0165656..5451eb0e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,3 +2,5 @@ rootProject.name = 'javapfb' include('service', 'client', 'integration') gradle.ext.releaseVersion = '0.11.0' +include 'java-pfb-cli' +