Skip to content

Commit

Permalink
Hello world CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
snf2ye committed Jun 22, 2023
1 parent 0ad18e7 commit 47919e4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions java-pfb-cli/README.md
Original file line number Diff line number Diff line change
@@ -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 <command> <args>
Only command right now: "hello"
30 changes: 30 additions & 0 deletions java-pfb-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
}
20 changes: 20 additions & 0 deletions java-pfb-cli/src/main/java/JavaPfbCommand.java
Original file line number Diff line number Diff line change
@@ -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!");
}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ rootProject.name = 'javapfb'
include('service', 'client', 'integration')

gradle.ext.releaseVersion = '0.11.0'
include 'java-pfb-cli'

0 comments on commit 47919e4

Please sign in to comment.