
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());
            }
        }
    }
}