Skip to content

Commit 7d90781

Browse files
committed
feat: change cli library
1 parent 6ae20ca commit 7d90781

File tree

11 files changed

+74
-80
lines changed

11 files changed

+74
-80
lines changed

backend/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
dependencies {
8-
api "commons-cli:commons-cli:1.9.0"
8+
api 'info.picocli:picocli:4.7.6'
99
implementation project(":core")
1010
implementation group: 'com.github.albfernandez', name: 'juniversalchardet', version: '2.4.0'
1111
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.github.kayjamlang.backend;
22

3-
import org.apache.commons.cli.CommandLine;
4-
import org.apache.commons.cli.CommandLineParser;
5-
import org.apache.commons.cli.Options;
6-
73
public interface IBackendCompiler {
8-
void addOptions(Options options);
9-
IBackendOptions parseOptions(CommandLine data);
4+
IBackendOptions createOptionsClass();
105
void compile(IOptions options) throws Exception;
116
}

backend/jvm/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies {
88
implementation project(":core")
99
implementation project(":backend:common")
1010
implementation 'org.ow2.asm:asm:9.7.1'
11+
annotationProcessor 'info.picocli:picocli-codegen:4.7.6'
1112
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
1213
testImplementation project(':core')
1314
}

backend/jvm/src/main/java/com/github/kayjamlang/backend/jvm/JVMBackendCompiler.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import com.github.kayjamlang.core.KayJamFile;
88
import com.github.kayjamlang.core.exceptions.KayJamLexerException;
99
import com.github.kayjamlang.core.exceptions.KayJamParserException;
10-
import org.apache.commons.cli.CommandLine;
11-
import org.apache.commons.cli.CommandLineParser;
12-
import org.apache.commons.cli.Options;
1310
import org.objectweb.asm.ClassWriter;
1411

1512
import java.io.File;
@@ -22,13 +19,8 @@ public class JVMBackendCompiler implements IBackendCompiler {
2219
public static final JVMBackendCompiler INSTANCE = new JVMBackendCompiler();
2320

2421
@Override
25-
public void addOptions(Options options) {
26-
27-
}
28-
29-
@Override
30-
public IBackendOptions parseOptions(CommandLine data) {
31-
return null;
22+
public IBackendOptions createOptionsClass() {
23+
return new JVMBackendOptions();
3224
}
3325

3426
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.github.kayjamlang.backend.jvm;
2+
3+
import com.github.kayjamlang.backend.IBackendOptions;
4+
import picocli.CommandLine;
5+
6+
@CommandLine.Command(name = "jvm", mixinStandardHelpOptions = true)
7+
public class JVMBackendOptions implements IBackendOptions {
8+
9+
}

backend/ts/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
dependencies {
88
implementation project(":core")
99
implementation project(":backend:common")
10+
annotationProcessor 'info.picocli:picocli-codegen:4.7.6'
1011
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
1112
testImplementation project(':core')
1213
}

backend/ts/src/main/java/com/github/kayjamlang/backend/ts/TSBackendCompiler.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,18 @@
77
import com.github.kayjamlang.core.KayJamFile;
88
import com.github.kayjamlang.core.exceptions.KayJamLexerException;
99
import com.github.kayjamlang.core.exceptions.KayJamParserException;
10-
import org.apache.commons.cli.CommandLine;
11-
import org.apache.commons.cli.CommandLineParser;
12-
import org.apache.commons.cli.Options;
1310

1411
import java.io.File;
1512
import java.io.FileOutputStream;
1613
import java.io.IOException;
1714
import java.util.List;
18-
import java.util.Map;
1915

2016
public class TSBackendCompiler implements IBackendCompiler {
2117
public static final TSBackendCompiler INSTANCE = new TSBackendCompiler();
2218

2319
@Override
24-
public void addOptions(Options options) {
25-
26-
}
27-
28-
@Override
29-
public IBackendOptions parseOptions(CommandLine data) {
30-
return null;
20+
public IBackendOptions createOptionsClass() {
21+
return new TSBackendOptions();
3122
}
3223

3324
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.github.kayjamlang.backend.ts;
2+
3+
import com.github.kayjamlang.backend.IBackendOptions;
4+
import picocli.CommandLine;
5+
6+
@CommandLine.Command(name = "ts", mixinStandardHelpOptions = true)
7+
public class TSBackendOptions implements IBackendOptions {
8+
9+
}

cli/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dependencies {
2424
implementation project(":backend:common")
2525
implementation project(":backend:jvm")
2626
implementation project(":backend:ts")
27-
implementation "commons-cli:commons-cli:1.9.0"
27+
implementation 'info.picocli:picocli:4.7.6'
28+
annotationProcessor 'info.picocli:picocli-codegen:4.7.6'
2829
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
2930
testImplementation project(':core')
3031
}

cli/scripts/kayjam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env sh
2-
java -jar /usr/share/kayjam/kayjam-cli.jar "$*"
2+
java -jar /usr/share/kayjam/kayjam-cli.jar $*

0 commit comments

Comments
 (0)