@Override
  public int run(String[] args) throws Exception {
    int exitCode = 1;

    for (int i = 0; i < args.length; ++i) {
      if (args[i].equals("create")) {
        if (i == args.length - 1) {
          return 1;
        }
        command = new CreateCommand();
        alias = args[++i];
        if (alias.equals("-h") || alias.equals("-help")) {
          printUsage();
          return 0;
        }
      } else if (args[i].equals("get")) {
        if (i == args.length - 1) {
          return 1;
        }
        command = new GetCommand();
        alias = args[++i];
        if (alias.equals("-h") || alias.equals("-help")) {
          printUsage();
          return 0;
        }
      } else if (args[i].equals("delete")) {
        if (i == args.length - 1) {
          printUsage();
          return 1;
        }
        command = new DeleteCommand();
        alias = args[++i];
        if (alias.equals("-help")) {
          printUsage();
          return 0;
        }
      } else if (args[i].equals("list")) {
        if (i < args.length - 1) {
          alias = args[i + 1];
        }
        command = new ListCommand();
        if (alias.equals("-h") || alias.equals("-help")) {
          printUsage();
          return 0;
        }
        alias = "not required";
      } else if (args[i].equals("-provider")) {
        if (i == args.length - 1) {
          return 1;
        }
        String providerPath = getNormalizedPath(args[++i]);
        getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerPath);
        provider = getCredentialProvider();
      } else if (args[i].equals("-f") || args[i].equals("-force")) {
        interactive = false;
        overwrite = true;
      } else if (args[i].equals("-n")) {
        interactive = false;
        overwrite = false;
      } else if (args[i].equals("-v") || args[i].equals("-value")) {
        value = args[++i];
      } else if (args[i].equals("-h") || args[i].equals("-help")) {
        printUsage();
        return 0;
      } else {
        printUsage();
        ToolRunner.printGenericCommandUsage(System.err);
        return 1;
      }
    }

    if (command == null) {
      printUsage();
    }
    else if (command.validate()) {
      exitCode = command.execute();
    }

    return exitCode;
  }
Called by ToolRunner.run(). This is the entry point to the tool.
Parses the command line arguments and executes the appropriate command.

@param args - Arguments supplied by the user.
@return - 0 if successful. 1 in case of a failure.
@throws Exception - If something goes wrong during command execution.
ambari-server/src/main/java/org/apache/ambari/server/credentialapi/CredentialUtil.java