import com.chicorycli.core.Command;
import com.chicorycli.core.CommandExecutionException;
import com.chicorycli.core.CommandExecutor;
import com.chicorycli.core.annotation.*;
import com.chicorycli.core.io.ConsoleIO;
public class Main {
public static void main(String[] args) {
try {
CommandExecutor.execute(args, Main.class);
} catch (CommandExecutionException e) {
ConsoleIO io = new ConsoleIO();
io.printError(e.getMessage());
}
}
@Command(name = "greet", description = "Say hello to someone")
public void greet(@Param(name = "name", description = "The name of the person") String name) {
System.out.println("Hello, " + name + "!");
}
@Command(name = "add", description = "Add two numbers")
public void add(@Param(name = "a", description = "The first number") int a,
@Param(name = "b", description = "The second number") int b) {
System.out.println(a + " + " + b + " = " + (a + b));
}
}
json
[
{
"name": "greet",
"method": "greet",
"params": [
{"name": "name", "type": "String", "description": "The name of the person"}
]
},
{
"name": "add",
"method": "add",
"params": [
{"name": "a", "type": "int", "description": "The first number"},
{"name": "b", "type": "int", "description": "The second number"}
]
}
]
java Main greet --name John
Hello, John!
java Main add --a 5 --b 3
5 + 3 = 8