diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
new file mode 100644
index 0000000..d124634
--- /dev/null
+++ b/.github/workflows/gradle.yml
@@ -0,0 +1,16 @@
+name: Java CI
+
+on: [push]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-java@v2
+ with:
+ distribution: 'temurin'
+ java-version: 19
+ - run: ./mvnw clean test
diff --git a/pom.xml b/pom.xml
index 36ed409..bd441a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,13 @@
${jbock.version}
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.9.1
+ test
+
+
@@ -73,6 +80,11 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.2.2
+
diff --git a/src/main/java/net/jbock/cp/Args.java b/src/main/java/net/jbock/cp/Args.java
index 50abbc4..53fd464 100644
--- a/src/main/java/net/jbock/cp/Args.java
+++ b/src/main/java/net/jbock/cp/Args.java
@@ -4,47 +4,44 @@
import net.jbock.Option;
import net.jbock.Parameter;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.nio.file.Path;
import java.util.Optional;
-import java.util.StringJoiner;
/**
* Copy SOURCE to DEST
*/
@Command(name = "cp")
-abstract class Args {
+interface Args {
/**
* Path or file of directory to copy.
* @return SOURCE
*/
@Parameter(index = 0)
- abstract Path source();
+ Path source();
/**
* Copy destination
* @return DEST
*/
@Parameter(index = 1)
- abstract Path dest();
+ Path dest();
/**
* Copy directories recursively
*/
@Option(names = {"--recursive", "-r"})
- abstract boolean recursive();
+ boolean recursive();
/**
* Make a backup of each existing destination file
*/
@Option(names = {"--backup", "-b"})
- abstract boolean backup();
+ boolean backup();
/**
* Override the usual backup suffix
*/
@Option(names = {"--suffix", "-s"})
- abstract Optional suffix();
+ Optional suffix();
}
diff --git a/src/test/java/net/jbock/cp/ArgsTest.java b/src/test/java/net/jbock/cp/ArgsTest.java
new file mode 100644
index 0000000..4939181
--- /dev/null
+++ b/src/test/java/net/jbock/cp/ArgsTest.java
@@ -0,0 +1,16 @@
+package net.jbock.cp;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ArgsTest {
+
+ @Test
+ void testPrint() {
+ Args result = new ArgsParser().parse(List.of("1", "2", "-rbs12")).getRight().orElseThrow();
+ assertEquals("{recursive: true, backup: true, suffix: Optional[12], source: 1, dest: 2}", result.toString());
+ }
+}