public static int execute()

in mr/src/main/java/org/elasticsearch/hadoop/cli/Keytool.java [44:91]


    public static int execute(Prompt console, String[] args) {
        Command command = null;
        String commandArg = null;
        boolean hasSTDIN = false;
        boolean force = false;
        for (int idx = 0; idx < args.length; idx++) {
            String arg = args[idx];
            if (arg.equals(FLAG_H) || arg.equals(FLAG_HELP)) {
                printUsage(console);
                return 0;
            } else if (hasSTDIN == false && (arg.equals(FLAG_STDIN))) {
                hasSTDIN = true;
            } else if (force == false && (arg.equals(FLAG_F) || arg.equals(FLAG_FORCE))) {
                force = true;
            } else if (command == null) {
                command = Command.byName(arg.toLowerCase());
                if (command == null) {
                    printUsage(console);
                    error(console, "Unknown command [" + arg + "]");
                    return 2;
                }
            } else if (command.hasArgs() && commandArg == null) {
                commandArg = arg;
            } else {
                printUsage(console);
                error(console, "Unexpected argument [" + arg + "]");
                return 3;
            }
        }
        if (command == null) {
            printUsage(console);
            error(console, "No command specified");
            return 1;
        }
        if (command.hasArgs && commandArg == null) {
            printUsage(console);
            error(console, "Settings name required for command [" + command.text + "]");
            return 4;
        }
        // If stdin is from a pipe, then the console will be null. Treat this like --stdin.
        hasSTDIN |= (System.console() == null);
        try {
            return new Keytool(console, command).run(commandArg, hasSTDIN, force);
        } catch (IOException e) {
            console.println("ERROR: " + e.getMessage());
            return 11;
        }
    }