forked from utPLSQL/utPLSQL-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCli.java
More file actions
46 lines (36 loc) · 1.22 KB
/
Cli.java
File metadata and controls
46 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package io.github.utplsql.cli;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
public class Cli {
public static final String HELP_CMD = "-h";
public static final String RUN_CMD = "run";
public static void main(String[] args) {
JCommander jc = new JCommander();
// jc.addCommand(HELP_CMD, new HelpCommand());
RunCommand runCmd = new RunCommand();
jc.addCommand(RUN_CMD, runCmd);
try {
jc.parse(args);
boolean hasCmd = jc.getParsedCommand() != null;
if (hasCmd && jc.getParsedCommand().equals(RUN_CMD)) {
runCmd.run();
} else {
jc.usage();
}
} catch (ParameterException e) {
if (jc.getParsedCommand() != null) {
System.err.println(e.getMessage());
jc.usage(jc.getParsedCommand());
} else {
jc.usage();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static class HelpCommand {
@Parameter(names = {HELP_CMD, "--help"}, help = true)
public boolean callHelp;
}
}