class OWL2Java {

    public static void main(String[] args) {

        if (args.length == 0) {
            System.out.println("Syntax: OWL2Java <command> <args>. Run 'OWL2Java help' for more details");
            return;
        }

        final Optional<Command> c = getCommand(args[0]);

        if (!c.isPresent()) {
            System.err
                    .println("Invalid command " + args[0] + ", try 'OWL2Java help' for the list of available commands");
            return;
        }

        final OptionParser op = c.get().parser;
        final OptionSet os = op.parse(args);
        final CliParams input = new CliParams(os);

        final OWL2JavaTransformer oj;

        switch (c.get()) {
            case help:
                if (args.length != 1) {
                    final Optional<Command> cc = getCommand(args[1]);
                    if (cc.isPresent()) {
                        printHelp(cc.get());
                    } else {
                        System.err.println("Invalid command " + args[0] + " " + args[1] +
                                ", try 'OWL2Java help' for the list of available commands.");
                        return;
                    }
                } else {
                    System.out.println("Available commands : " + Arrays.asList(Command.values()));
                }
                break;
            case list:
                if (invalidArgumentCount(input)) {
                    break;
                }
                oj = getTransformer(input);

                System.out.println("Available contexts: " + oj.listContexts());
                break;
            case transform:
                if (invalidArgumentCount(input)) {
                    break;
                }
                transformOwlToJava(input);
                break;
            case vocabulary:
                if (invalidArgumentCount(input)) {
                    break;
                }
                generateVocabulary(input);
                break;
            case version:
                System.out.println("OWL2Java version " + Constants.VERSION);
                break;
            default:
                System.err.println("Unknown command '" + args[0] + "', try 'OWL2Java help'.");
        }
    }

}