Parses command line configuration into an object structure, validates
correct values along the way.

Prints a help message and exits the JVM on parse failure.

@param args command line configuration values
@return populated SyncToolConfig
516430
public SyncToolConfig processCommandLine(String[] args) {
        SyncToolConfig config = null;
        try {
            config = processConfigFileOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }
        return config;
    }
1225772
private void parseArgs(String[] args) {
        int index = 0;
        while (index < args.length) {
            String name = args[index];
            if (name.equals("-?") || name.equalsIgnoreCase("-help")) {
                usage();
            }
            if (name.charAt(0) != '-') {
                m_logger.error("Unrecognized parameter: {}", name);
                usage();
            }
            if (++index >= args.length) {
                m_logger.error("Another parameter expected after '{}'", name);
                usage();
            }
            String value = args[index];
            try {
                m_config.set(name.substring(1), value);
            } catch (Exception e) {
                m_logger.error(e.toString());
                usage();
            }
            index++;
        }
    }
804554
public static ReportGenerator.Format getFormat( String... args ) {
        ConfigOptionParser configParser = new ConfigOptionParser();
        List<ConfigOption> configOptions = Arrays.asList( format, help );

        for( ConfigOption co : configOptions ) {
            if( co.hasDefault() ) {
                configParser.parsedOptions.put( co.getLongName(), co.getValue() );
            }
        }

        for( String arg : args ) {
            configParser.commandLineLookup( arg, format, configOptions );
        }

        // TODO properties
        // TODO environment

        if( !configParser.hasValue( format ) ) {
            configParser.printUsageAndExit( configOptions );
        }
        return (ReportGenerator.Format) configParser.getValue( format );
    }
1008509
public static void main(String[] args) {
		try {
			// get the config directory first
			String configDir = null;

			if (args.length >= 2 && args[0].equals("-configDir")) {
				configDir = args[1];
			}

			if (configDir == null) {
				System.err
					.println("Error: Configuration directory must be specified.\nWebFrontend -configDir <directory>\n");
				System.exit(1);
				return;
			}

			// load the global configuration
			GlobalConfiguration.loadConfiguration(configDir);
			Configuration config = GlobalConfiguration.getConfiguration();
			
			// add stratosphere base dir to config
			config.setString(ConfigConstants.STRATOSPHERE_BASE_DIR_PATH_KEY, configDir+"/..");

			// get the listening port
			int port = config.getInteger(ConfigConstants.WEB_FRONTEND_PORT_KEY,
				ConfigConstants.DEFAULT_WEBCLIENT_PORT);

			// start the server
			WebInterfaceServer server = new WebInterfaceServer(config, port);
			LOG.info("Starting web frontend server on port " + port + '.');
			server.start();
			server.join();
		} catch (Throwable t) {
			LOG.error("Unexpected exception: " + t.getMessage(), t);
		}
	}
493826
public static void main(final String[] args) {
    LOG.log(Level.INFO, "Entering Launch at :::" + new Date());
    try {
      if (args == null || args.length == 0) {
        throw new IllegalArgumentException("No arguments provided, at least a clrFolder should be supplied.");
      }
      final File dotNetFolder = new File(args[0]).getAbsoluteFile();
      final String[] removedArgs = Arrays.copyOfRange(args, 1, args.length);

      final Configuration config = getClientConfiguration(removedArgs);
      final Injector commandLineInjector = Tang.Factory.getTang().newInjector(parseCommandLine(removedArgs));
      final int waitTime = commandLineInjector.getNamedInstance(WaitTimeForDriver.class);
      final int driverMemory = commandLineInjector.getNamedInstance(DriverMemoryInMb.class);
      final boolean isLocal = commandLineInjector.getNamedInstance(Local.class);
      final String driverIdentifier = commandLineInjector.getNamedInstance(DriverIdentifier.class);
      final String jobSubmissionDirectory = commandLineInjector.getNamedInstance(DriverJobSubmissionDirectory.class);
      final boolean submit = commandLineInjector.getNamedInstance(Submit.class);
      final Injector injector = Tang.Factory.getTang().newInjector(config);
      final JobClient client = injector.getInstance(JobClient.class);
      client.setDriverInfo(driverIdentifier, driverMemory, jobSubmissionDirectory);

      if (submit) {
        client.submit(dotNetFolder, true, isLocal, null);
        client.waitForCompletion(waitTime);
      } else {
        client.submit(dotNetFolder, false, isLocal, config);
        client.waitForCompletion(0);
      }


      LOG.info("Done!");
    } catch (final BindException | InjectionException | IOException ex) {
      LOG.log(Level.SEVERE, "Job configuration error", ex);
    }
  }
252360
public static void main(String[] args) throws Exception {
        final CodeGeneratorConfig config = new CodeGeneratorConfig();
        final JCommander commander = new JCommander(config);
        commander.parse(args);

        if (config.help) {
            commander.usage();
            System.exit(0);
        }

        // make sure the logger is initialized
        CodeGeneratorLoggerFactory.setLogger(new CodeGeneratorSimpleLogger());

        // iff baseFolder is null or empty, reset it to the default value
        config.baseFolder = StringUtils.defaultIfEmpty(config.baseFolder, "GUIData");

        // create the helper with our config
        CodeGeneratorHelper helper = new CodeGeneratorHelper(config);

        if (CodeGeneratorLoggerFactory.getLogger().isDebugEnabled()) {
            helper.displayProjectInformation();
        }

        // register all custom element classes
        helper.registerCustomElements();

        // process the files.
        helper.processFiles();
    }
303036
public static void main(String[] args) {
    System.exit(getConf(
        ClientContext.create(new InstancedConfiguration(ConfigurationUtils.defaults())), args));
  }
292839
public String[] parse(String[] args) throws ArgException {

    List<String> nonOptions = new ArrayList<>();
    // If true, then "--" has been seen and any argument starting with "-"
    // is processed as an ordinary argument, not as an option.
    boolean ignoreOptions = false;

    // Loop through each argument
    String tail = "";
    String arg;
    for (int ii = 0; ii < args.length; ) {
      // If there was a ',' separator in previous arg, use the tail as
      // current arg; otherwise, fetch the next arg from args list.
      if (tail.length() > 0) {
        arg = tail;
        tail = "";
      } else {
        arg = args[ii];
      }

      if (arg.equals("--")) {
        ignoreOptions = true;
      } else if ((arg.startsWith("--") || arg.startsWith("-")) && !ignoreOptions) {
        String argName;
        String argValue;

        // Allow ',' as an argument separator to get around
        // some command line quoting problems.  (markro)
        int splitPos = arg.indexOf(",-");
        if (splitPos == 0) {
          // Just discard the ',' if ",-" occurs at begining of string
          arg = arg.substring(1);
          splitPos = arg.indexOf(",-");
        }
        if (splitPos > 0) {
          tail = arg.substring(splitPos + 1);
          arg = arg.substring(0, splitPos);
        }

        int eqPos = arg.indexOf('=');
        if (eqPos == -1) {
          argName = arg;
          argValue = null;
        } else {
          argName = arg.substring(0, eqPos);
          argValue = arg.substring(eqPos + 1);
        }
        OptionInfo oi = nameMap.get(argName);
        if (oi == null) {
          StringBuilder msg = new StringBuilder();
          msg.append(String.format("unknown option name '%s' in arg '%s'", argName, arg));
          if (false) { // for debugging
            msg.append("; known options:");
            for (String optionName : sortedKeySet(nameMap)) {
              msg.append(" ");
              msg.append(optionName);
            }
          }
          throw new ArgException(msg.toString());
        }
        if (oi.argumentRequired() && (argValue == null)) {
          ii++;
          if (ii >= args.length) {
            throw new ArgException("option %s requires an argument", arg);
          }
          argValue = args[ii];
        }
        // System.out.printf ("argName = '%s', argValue='%s'%n", argName,
        //                    argValue);
        setArg(oi, argName, argValue);
      } else { // not an option
        if (!parseAfterArg) {
          ignoreOptions = true;
        }
        nonOptions.add(arg);
      }

      // If no ',' tail, advance to next args option
      if (tail.length() == 0) {
        ii++;
      }
    }
    String[] result = nonOptions.toArray(new String[nonOptions.size()]);
    return result;
  }
1027817
public static int getConf(ClientContext ctx, String... args) {
    return getConfImpl(
        () -> new RetryHandlingMetaMasterConfigClient(MasterClientContext.newBuilder(ctx).build()),
        ctx.getConf(), args);
  }
272529
public String[] parse(@NonNull String[] args) {
      List<String> filtered = new ArrayList<>();
      List<String> cleanedArgs = new ArrayList<>();

      //Pass through the args once to do a clean up will make the next round easier to parser.
      for (String c : args) {
         if (c.endsWith(KEY_VALUE_SEPARATOR) && isOptionName(c)) {
            //If it is ends with a key/value separator and is an option
            //lets separate them into two tokens.
            cleanedArgs.add(c.substring(0, c.length() - 1));
            cleanedArgs.add(KEY_VALUE_SEPARATOR);
         } else if (c.contains(KEY_VALUE_SEPARATOR) && isOptionName(c)) {
            //If it contains a key/value separator, but doesn't end in one and is an option
            //then we have a key value pair that will split into three tokens [key, =, value]
            int index = c.lastIndexOf(KEY_VALUE_SEPARATOR);
            cleanedArgs.add(c.substring(0, index));
            cleanedArgs.add(KEY_VALUE_SEPARATOR);
            cleanedArgs.add(c.substring(index + KEY_VALUE_SEPARATOR.length()));
         } else if (StringUtils.isNotNullOrBlank(c)) {
            //Anything else that isn't null or blank we keep as is
            cleanedArgs.add(c);
         }
      }

      for (int i = 0; i < cleanedArgs.size(); i++) {
         String current = cleanedArgs.get(i);

         //Check that the token isn't just a long or short argument marker.
         if (LONG.equals(current) || SHORT.equals(current)) {
            throw new CommandLineParserException(current, null);
         }

         if (current.startsWith(LONG)) {
            //We have a long form argument.
            String value = "true";
            String next = peek(cleanedArgs, i + 1);
            if (next.equalsIgnoreCase(KEY_VALUE_SEPARATOR)) {
               //If are peeked at value is our key value separator then lets set the value to what comes after.
               value = peek(cleanedArgs, i + 2);
               if (isOptionName(value)) {
                  //If the value is an option name, we have an error
                  throw new CommandLineParserException(current, null);
               }
               i += 2;
            } else if (!isOptionName(next)) {
               //If are peeked at value isn't our key value separator and isn't another option name, lets set the value to what comes after.
               i++;
               value = next;
            }
            setValue(current, value, filtered);
         } else if (current.startsWith(SHORT)) {
            //We have a short form argument.
            //Are we setting multiple "boolean" values?
            if (current.length() > 2) {
               //All of these will be set to true
               char[] opts = current.substring(1).toCharArray();
               for (char c : opts) {
                  setValue("-" + c, "true", filtered);
               }
            } else {
               String value = "true";
               String next = peek(cleanedArgs, i + 1);
               if (next.equalsIgnoreCase(KEY_VALUE_SEPARATOR)) {
                  //If are peeked at value is our key value separator then lets set the value to what comes after.
                  value = peek(cleanedArgs, i + 2);
                  if (isOptionName(value)) {
                     //If the value is an option name, we have an error
                     throw new CommandLineParserException(current, null);
                  }
                  i += 2;
               } else if (!isOptionName(next)) {
                  //If are peeked at value isn't our key value separator and isn't another option name, lets set the value to what comes after.
                  i++;
                  value = next;
               }
               setValue(current, value, filtered);
            }

         } else {
            filtered.add(current);
         }

      }

      //Check if the help was set, if a required argument was not set, and try to set the associated field on the owner object if one is set.
      optionSet.forEach(Unchecked.consumer(option -> {
         if (option.getName().equals("h") && Cast.<Boolean>as(option.getValue())) {
            showHelp();
            System.exit(0);
         } else if (option.isRequired() && !isSet(option.getName())) {
            System.err.println("ERROR: " + option.getName() + " is required, but was not set.");
            showHelp();
            System.exit(-1);
         }

         if (owner != null && option.getField() != null) {
            Reflect.onObject(owner).allowPrivilegedAccess().set(option.getField().getName(), option.getValue());
         }
      }));

      return filtered.toArray(new String[filtered.size()]);
   }
152866
public void run(String[] args) {
    // Add and parse options.
    OptionParser parser = new OptionParser();
    initializeCommonOptions(parser);
    initializeOptions(parser);

    String errorMessage = null;
    try {
      parsedOptions = parser.parse(args);
    } catch (OptionException e) {
      errorMessage = e.getMessage();
    }

    boolean printHelp = false;
    if (errorMessage != null) {
      // If an error occurs, the options don't parse.
      // Therefore, we must manually check if the help option was
      // given.
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("--help")) {
          printHelp = true;
        }
      }
    }

    if (errorMessage != null && !printHelp) {
      System.err.println(errorMessage);
      System.err.println("Try --help for more information about options.");
      System.exit(1);
    }

    if (printHelp || parsedOptions.has(helpOpt)) {
      // If a help option is given, print help then quit.
      try {
        parser.printHelpOn(System.err);
      } catch (IOException ioException) {
        throw new RuntimeException(ioException);
      }
      System.exit(0);
    }

    // Log any passed-in options.
    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Command-line options:");
      for (OptionSpec<?> optionSpec : parsedOptions.specs()) {
        if (parsedOptions.hasArgument(optionSpec)) {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), "") + " "
              + Joiner.on(" ").join(parsedOptions.valuesOf(optionSpec)));
        } else {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), ""));
        }
      }
      System.out.println("");
    }

    // Run the program.
    long startTime = System.currentTimeMillis();
    processOptions(parsedOptions);
    run(parsedOptions);
    long endTime = System.currentTimeMillis();

    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Total time elapsed: " + TimeUtils.durationToString(endTime - startTime));
    }

    System.exit(0);
  }
1067961
private void parse(String[] args) {
        for (int i=0; i<args.length; i++) {
            if (opt_with_value.containsKey(args[i])) {
                String key = opt_with_value.get(args[i]);
                values.put(key, args[i+1]);
                i++;
            } else if (args[i].startsWith("-")) {
                opt_without_value.add(args[i]);
            } else {
                arglist.add(args[i]);
            }
        }
    }
929926
protected static Map<String, String> initializeSystemProperties(final String[] args) {
        final Map<String, String> result = new HashMap<>();
        final Pattern pattern = Pattern.compile("-D(.+)=(.+)");
        for (final String arg : args) {
            final Matcher matcher = pattern.matcher(arg);
            if (matcher.matches()) {
                final String key = matcher.group(1);
                final String value = matcher.group(2);
                result.put(key, value);
                System.setProperty(key, value);
            }
        }
        return result;
    }
933855
public static void main(String[] args)
            throws YamlConvertException, IllegalDataStructureException, IllegalTestScriptException {
        if (args.length == 0) {
            throw new IllegalArgumentException(MSG_NO_COMMAND_LINE_ARGUMENT);
        }
        Action action = null;
        try {
            action = Action.getEnum(args[0]);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(String.format(MSG_UNKNOWN_ACTION, args[0]));
        }
        String configFilePath;
        if (args.length <= 1) {
            configFilePath = "sahagin.yml";
        } else {
            configFilePath = args[1];
        }
        File configFile = new File(configFilePath);
        if (!configFile.exists()) {
            throw new IllegalArgumentException(String.format(
                    MSG_CONFIG_NOT_FOUND, configFile.getAbsolutePath()));
        }
        Config config = Config.generateFromYamlConfig(configFile);
        Logging.setLoggerEnabled(config.isOutputLog());
        AcceptableLocales locales = AcceptableLocales.getInstance(config.getUserLocale());
        SysMessages.globalInitialize(locales);

        switch (action) {
        case Report:
            report(config);
            break;
        default:
            throw new RuntimeException("implementation error");
        }
    }
979198
public static void main(final String[] args) {
    GUIUtil.logUncaughtExceptions(LOG);
    GUIUtil.setLookAndFeel();
    OutputStep.setDefaultHandlerVisualizer();

    javax.swing.SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        try {
          final MultiStepGUI gui = new MultiStepGUI();
          gui.run();
          if(args != null && args.length > 0) {
            gui.setParameters(new SerializedParameterization(args));
          }
          else {
            gui.setParameters(new SerializedParameterization());
          }
        }
        catch(Exception | Error e) {
          // Restore error handler, as the GUI is likely broken.
          LoggingConfiguration.replaceDefaultHandler(new CLISmartHandler());
          LOG.exception(e);
        }
      }
    });
  }
332164
String[] parseArgs(String[] args) {
    int i = 0;
    boolean driverArgs = true;
    while (driverArgs) {
      if (i >= args.length) {
        break;
      }

      String s = args[i];
      if (s.equals("-h") ||
              s.equals("help") ||
              s.equals("-help") ||
              s.equals("--help")) {
        usage();
      }
      else if (s.equals("-n") ||
              s.equals("-nodes")) {
        i++; if (i >= args.length) { usage(); }
        numNodes = Integer.parseInt(args[i]);
      }
      else if (s.equals("-o") ||
              s.equals("-output")) {
        i++; if (i >= args.length) { usage(); }
        outputPath = args[i];
      }
      else if (s.equals("-jobname")) {
        i++; if (i >= args.length) { usage(); }
        jobtrackerName = args[i];
      }
      else if (s.equals("-mapperXmx")) {
        i++; if (i >= args.length) { usage(); }
        mapperXmx = args[i];
      }
      else if (s.equals("-extramempercent")) {
        i++; if (i >= args.length) { usage(); }
        extraMemPercent = Integer.parseInt(args[i]);
      }
      else if (s.equals("-mapperPermSize")) {
        i++; if (i >= args.length) { usage(); }
        mapperPermSize = args[i];
      }
      else if (s.equals("-driverif")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackIp = args[i];
      }
      else if (s.equals("-driverport")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackPort = Integer.parseInt(args[i]);
      }
      else if (s.equals("-driverportrange")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackPortRange = PortRange.parse(args[i]);
      }
      else if (s.equals("-network")) {
        i++; if (i >= args.length) { usage(); }
        network = args[i];
      }
      else if (s.equals("-timeout")) {
        i++; if (i >= args.length) { usage(); }
        cloudFormationTimeoutSeconds = Integer.parseInt(args[i]);
      }
      else if (s.equals("-disown")) {
        disown = true;
      }
      else if (s.equals("-notify")) {
        i++; if (i >= args.length) { usage(); }
        clusterReadyFileName = args[i];
      }
      else if (s.equals("-nthreads")) {
        i++; if (i >= args.length) { usage(); }
        nthreads = Integer.parseInt(args[i]);
      }
      else if (s.equals("-context_path")) {
        i++; if (i >= args.length) { usage(); }
        contextPath = args[i];
      }
      else if (s.equals("-baseport")) {
        i++; if (i >= args.length) { usage(); }
        basePort = Integer.parseInt(args[i]);
        if ((basePort < 0) || (basePort > 65535)) {
            error("Base port must be between 1 and 65535");
        }
      }
      else if (s.equals("-port_offset")) {
        i++; if (i >= args.length) { usage(); }
        portOffset = Integer.parseInt(args[i]);
        if ((portOffset <= 0) || (portOffset > 65534)) {
          error("Port offset must be between 1 and 65534");
        }
      }
      else if (s.equals("-beta")) {
        beta = true;
      }
      else if (s.equals("-random_udp_drop")) {
        enableRandomUdpDrop = true;
      }
      else if (s.equals("-ea")) {
        enableExceptions = true;
      }
      else if (s.equals("-verbose:gc") && !JAVA_VERSION.useUnifiedLogging()) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enableVerboseGC = true;
        } else {
          error("Parameter -verbose:gc is unusable, running on JVM with deprecated GC debugging flags.");
        }
      } else if (s.equals("-Xlog:gc=info")) {
        if (JAVA_VERSION.useUnifiedLogging()) {
          enableVerboseGC = true;
        } else {
          error("Parameter -verbose:gc is unusable, running on JVM without unified JVM logging.");
        }
      }
      else if (s.equals("-verbose:class")) {
        enableVerboseClass = true;
      }
      else if (s.equals("-XX:+PrintCompilation")) {
        enablePrintCompilation = true;
      }
      else if (s.equals("-exclude")) {
        enableExcludeMethods = true;
      }
      else if (s.equals("-Dlog4j.defaultInitOverride=true")) {
        enableLog4jDefaultInitOverride = true;
      }
      else if (s.equals("-debug")) {
        enableDebug = true;
      }
      else if (s.equals("-suspend")) {
        enableSuspend = true;
      }
      else if (s.equals("-debugport")) {
        i++; if (i >= args.length) { usage(); }
        debugPort = Integer.parseInt(args[i]);
        if ((debugPort < 0) || (debugPort > 65535)) {
          error("Debug port must be between 1 and 65535");
        }
      } else if (s.equals("-XX:+PrintGCDetails")) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enablePrintGCDetails = true;
        } else {
          error("Parameter -XX:+PrintGCDetails is unusable, running on JVM with deprecated GC debugging flags.");
        }
      }
      else if (s.equals("-XX:+PrintGCTimeStamps")) {
        if (!JAVA_VERSION.useUnifiedLogging()) {
          enablePrintGCDetails = true;
        } else {
          error("Parameter -XX:+PrintGCTimeStamps is unusable, running on JVM with deprecated GC debugging flags.");
        }
      }
      else if (s.equals("-gc")) {
        enableVerboseGC = true;
        enablePrintGCDetails = true;
        enablePrintGCTimeStamps = true;
      }
      else if (s.equals("-nogc")) {
        enableVerboseGC = false;
        enablePrintGCDetails = false;
        enablePrintGCTimeStamps = false;
      }
      else if (s.equals("-flow_dir")) {
        i++; if (i >= args.length) { usage(); }
        flowDir = args[i];
      }
      else if (s.equals("-J")) {
        i++; if (i >= args.length) { usage(); }
        extraArguments.add(args[i]);
      }
      else if (s.equals("-JJ")) {
        i++; if (i >= args.length) { usage(); }
        extraJvmArguments.add(args[i]);
      }
      else if (s.equals("-jks")) {
        i++; if (i >= args.length) { usage(); }
        jksFileName = args[i];
      }
      else if (s.equals("-jks_pass")) {
        i++; if (i >= args.length) { usage(); }
        jksPass = args[i];
      }
      else if (s.equals("-internal_secure_connections")) {
        internal_secure_connections = true;
      }
      else if (s.equals("-internal_security_conf") || s.equals("-internal_security")) {
        if(s.equals("-internal_security")){
          System.out.println("The '-internal_security' configuration is deprecated. " +
                  "Please use '-internal_security_conf' instead.");
        }
        i++; if (i >= args.length) { usage(); }
        securityConf = args[i];
      }
      else if (s.equals("-hash_login")) {
        hashLogin = true;
      }
      else if (s.equals("-ldap_login")) {
        ldapLogin = true;
      }
      else if (s.equals("-kerberos_login")) {
        kerberosLogin = true;
      }
      else if (s.equals("-pam_login")) {
        pamLogin = true;
      }
      else if (s.equals("-login_conf")) {
        i++; if (i >= args.length) { usage(); }
        loginConfFileName = args[i];
      }
      else if (s.equals("-form_auth")) {
        formAuth = true;
      }
      else if (s.equals("-session_timeout")) {
        i++; if (i >= args.length) { usage(); }
        sessionTimeout = args[i];
      }
      else if (s.equals("-user_name")) {
        i++; if (i >= args.length) { usage(); }
        userName = args[i];
      }
      else if (s.equals("-client")) {
        client = true;
        driverArgs = false;
      }
      else if (s.equals("-proxy")) {
        proxy = true;
        driverArgs = false;
      } else if (s.equals("-run_as_user")) {
        i++; if (i >= args.length) { usage(); }
        runAsUser = args[i];
      } else if (s.equals("-principal")) {
        i++; if (i >= args.length) { usage(); }
        principal = args[i];
      } else if (s.equals("-keytab")) {
        i++; if (i >= args.length) { usage (); }
        keytabPath = args[i];
      } else if (s.equals("-report_hostname")) {
        reportHostname = true;
      } else if (s.equals("-driver_debug")) {
        driverDebug = true;
      } else if (s.equals("-hiveHost")) {
        i++; if (i >= args.length) { usage (); }
        hiveHost = args[i];
      } else if (s.equals("-hivePrincipal")) {
        i++; if (i >= args.length) { usage (); }
        hivePrincipal = args[i];
      } else if (s.equals("-refreshTokens")) {
        refreshTokens = true;
      } else {
        error("Unrecognized option " + s);
      }

      i++;
    }
    String[] otherArgs = new String[Math.max(args.length - i, 0)];
    for (int j = 0; j < otherArgs.length; j++)
      otherArgs[j] = args[i++];
    return otherArgs;
  }
253452
public static void main(final String[] args) {
		EnvironmentInformation.logEnvironmentInfo(LOG, "Command Line Client", args);

		// 1. find the configuration directory
		final String configurationDirectory = getConfigurationDirectoryFromEnv();

		// 2. load the global configuration
		final Configuration configuration = GlobalConfiguration.loadConfiguration(configurationDirectory);

		// 3. load the custom command lines
		final List<CustomCommandLine<?>> customCommandLines = loadCustomCommandLines(
			configuration,
			configurationDirectory);

		try {
			final CliFrontend cli = new CliFrontend(
				configuration,
				customCommandLines);

			SecurityUtils.install(new SecurityConfiguration(cli.configuration));
			int retCode = SecurityUtils.getInstalledContext()
					.runSecured(() -> cli.parseParameters(args));
			System.exit(retCode);
		}
		catch (Throwable t) {
			final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
			LOG.error("Fatal error while running command line interface.", strippedThrowable);
			strippedThrowable.printStackTrace();
			System.exit(31);
		}
	}