public CommandLine process(String[] argv) { try { return new GnuParser().parse(options, argv); } catch (ParseException e) { throw new RuntimeException(e); } }
private CommandLine parseOpts(String cmdName, Options opts, String[] argv) { try { // Strip off the first arg, since that's just the command name argv = Arrays.copyOfRange(argv, 1, argv.length); return new GnuParser().parse(opts, argv); } catch (ParseException pe) { errOut.println(cmdName.substring(1) + ": incorrect arguments"); printUsage(errOut, cmdName); return null; } }
public boolean process(String []argv){ try { commandLine = new GnuParser().parse(options, argv); if(commandLine.hasOption("help")){ printCliUsage(); return false; } } catch (ParseException e) { System.err.println(e.getMessage()); printCliUsage(); return false; } return true; }
/** * Parses the command line arguments. * * @param argv the command line arguments * @return true, if successful */ public boolean parse(String[] argv) { try { commandLine = new GnuParser().parse(options, argv); } catch (ParseException ex) { System.err.println(ex.getMessage()); //NOSONAR printUsage(); return false; } return true; }
/** * Parse command line options */ public boolean init(String[] args) throws ParseException { CommandLine cliParser = new GnuParser().parse(jstormClientContext.opts, args); if (cliParser.hasOption(JOYConstants.HELP)) { printUsage(); return false; } jstormClientContext.appName = cliParser.getOptionValue(JOYConstants.APP_NAME_KEY, JOYConstants.CLIIENT_CLASS); jstormClientContext.amPriority = Integer.parseInt(cliParser.getOptionValue(JOYConstants.PRIORITY, JOYConstants.DEFAULT_PRIORITY)); jstormClientContext.amQueue = cliParser.getOptionValue(JOYConstants.QUEUE, JOYConstants.QUEUE_NAME); jstormClientContext.amMemory = Integer.parseInt(cliParser.getOptionValue(JOYConstants.MASTER_MEMORY, JOYConstants.DEFAULT_MASTER_MEMORY)); jstormClientContext.amVCores = Integer.parseInt(cliParser.getOptionValue(JOYConstants.MASTER_VCORES, JOYConstants.DEFAULT_MASTER_VCORES)); jstormClientContext.appMasterJar = cliParser.getOptionValue(JOYConstants.JAR); jstormClientContext.libJars = cliParser.getOptionValue(JOYConstants.LIB_JAR); jstormClientContext.homeDir = cliParser.getOptionValue(JOYConstants.HOME_DIR); jstormClientContext.confFile = cliParser.getOptionValue(JOYConstants.CONF_FILE); jstormClientContext.rmHost = cliParser.getOptionValue(JOYConstants.RM_ADDRESS, JOYConstants.EMPTY); jstormClientContext.nameNodeHost = cliParser.getOptionValue(JOYConstants.NN_ADDRESS, JOYConstants.EMPTY); jstormClientContext.deployPath = cliParser.getOptionValue(JOYConstants.DEPLOY_PATH, JOYConstants.EMPTY); jstormClientContext.hadoopConfDir = cliParser.getOptionValue(JOYConstants.HADOOP_CONF_DIR, JOYConstants.EMPTY); jstormClientContext.instanceName = cliParser.getOptionValue(JOYConstants.INSTANCE_NAME, JOYConstants.EMPTY); JstormYarnUtils.checkAndSetOptions(cliParser, jstormClientContext); return true; }
/** * Parse the arguments. * @param args */ public void parse(String[] args) { try { commandLine = new GnuParser().parse(OPTIONS, args); if (commandLine.hasOption('h')) { printUsage(); System.exit(1); } if (commandLine.hasOption('v')) { verbose = true; } } catch (ParseException e) { System.err.println(e.getMessage()); printUsage(); System.exit(1); } }
/** * Parse the arguments. * @param args */ public void parse(String[] args) { try { commandLine = new GnuParser().parse(OPTIONS, args); if (commandLine.hasOption('h')) { printUsage(); System.exit(1); } if (commandLine.hasOption('v')) { verbose = true; } } catch (ParseException e) { System.err.println(e.getMessage()); printUsage(); System.exit(1); } }
CommandLine cliParser = new GnuParser().parse(opts, args); JstormYarnUtils.checkAndSetMasterOptions(cliParser, jstormMasterContext, this.conf); } catch (Exception e) {
private void parseCommandLine(String[] args) throws ParseException { CommandLine cl = new GnuParser().parse(OPTIONS, args); listFSRoot = cl.hasOption(LIST_FS_ROOT.getOpt()); jdoqlQuery = cl.getOptionValue(EXECUTE_JDOQL.getOpt()); updateLocationParams = cl.getOptionValues(UPDATE_LOCATION.getOpt()); dryRun = cl.hasOption(DRY_RUN.getOpt()); serdePropKey = cl.getOptionValue(SERDE_PROP_KEY.getOpt()); tablePropKey = cl.getOptionValue(TABLE_PROP_KEY.getOpt()); help = cl.hasOption(HELP.getOpt()); int commandCount = (isListFSRoot() ? 1 : 0) + (isExecuteJDOQL() ? 1 : 0) + (isUpdateLocation() ? 1 : 0); if (commandCount != 1) { throw new IllegalArgumentException("exectly one of -listFSRoot, -executeJDOQL, -updateLocation must be set"); } if (updateLocationParams != null && updateLocationParams.length != 2) { throw new IllegalArgumentException("HiveMetaTool:updateLocation takes in 2 arguments but was passed " + updateLocationParams.length + " arguments"); } if ((dryRun || serdePropKey != null || tablePropKey != null) && !isUpdateLocation()) { throw new IllegalArgumentException("-dryRun, -serdePropKey, -tablePropKey may be used only for the " + "-updateLocation command"); } }
/** * Parse the command line arguments */ public boolean parse(String[] args) { try { commandLine = new GnuParser().parse(options, args); execString = commandLine.getOptionValue('e'); fileName = commandLine.getOptionValue('f'); main = commandLine.getOptionValue("main"); Properties p = commandLine.getOptionProperties("hiveconf"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } p = commandLine.getOptionProperties("hivevar"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } p = commandLine.getOptionProperties("define"); for(String key : p.stringPropertyNames()) { vars.put(key, p.getProperty(key)); } } catch (ParseException e) { System.err.println(e.getMessage()); return false; } return true; }
CommandLine cli = new GnuParser().parse(opts, args);
public boolean process_stage1(String[] argv) { try { commandLine = new GnuParser().parse(options, argv); Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { // with HIVE-11304, hive.root.logger cannot have both logger name and log level. // if we still see it, split logger and level separately for hive.root.logger // and hive.log.level respectively if (propKey.equalsIgnoreCase("hive.root.logger")) { CommonCliOptions.splitAndSetLogger(propKey, confProps); } else { System.setProperty(propKey, confProps.getProperty(propKey)); } } Properties hiveVars = commandLine.getOptionProperties("define"); for (String propKey : hiveVars.stringPropertyNames()) { hiveVariables.put(propKey, hiveVars.getProperty(propKey)); } Properties hiveVars2 = commandLine.getOptionProperties("hivevar"); for (String propKey : hiveVars2.stringPropertyNames()) { hiveVariables.put(propKey, hiveVars2.getProperty(propKey)); } } catch (ParseException e) { System.err.println(e.getMessage()); printUsage(); return false; } return true; }
public LlapOptions processOptions(String argv[]) throws ParseException, IOException { commandLine = new GnuParser().parse(options, argv); if (commandLine.hasOption('H') || false == commandLine.hasOption("instances")) {
public static void main(String[] args) throws Exception { RunOptions runOptions; try { Options opts = createOptions(); CommandLine cli = new GnuParser().parse(opts, args); if (cli.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(HiveStrictManagedMigration.class.getName(), opts); return; } runOptions = createRunOptions(cli); } catch (Exception err) { throw new Exception("Error processing options", err); } int rc = 0; HiveStrictManagedMigration migration = null; try { migration = new HiveStrictManagedMigration(runOptions); migration.run(); } catch (Exception err) { LOG.error("Failed with error", err); rc = -1; } finally { if (migration != null) { migration.cleanup(); } } // TODO: Something is preventing the process from terminating after main(), adding exit() as hacky solution. System.exit(rc); }
public static void main(String[] args) throws Exception { Options opts = createOptions(); CommandLine cli = new GnuParser().parse(opts, args);
private void parseCommandLine(String[] args) throws ParseException { CommandLine cl = new GnuParser().parse(OPTIONS, args);
CommandLine cli = new GnuParser().parse(opts, args);
ServerOptionsProcessorResponse parse(String[] argv) { try { commandLine = new GnuParser().parse(options, argv);
CommandLine cli = new GnuParser().parse(opts, args);