This repository has been archived on 2022-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
LinkDitch/Documentation/Main.java

36 lines
1021 B
Java
Raw Normal View History

2022-05-22 18:05:10 +02:00
public class Main {
public static void main(String[] args) {
System.out.print("success");
}
abstract public class Subcommand {
public String executeSubcommand(String[] args);
final public HashMap<String, Function<String[], String>> commands =
new HashMap<>();
abstract public String getSubcommand();
abstract public String getUsage();
public String executeSubcommand(String[] args) {
try {
commandExsits(args[0]);
return commands.get(args[0]).apply(args);
}
catch (IndexOutOfBoundsException e) {
throw new CliError("Missing a value! " +
getUsage());
}
}
private void commandExsits(String command) {
if (commands.get(command) == null) {
throw new CliError("Subcommand does not exist! " +
getUsage());
}
}
}
}