public static void run(Config conf, Tool tool, String[] args) { try { if (conf == null) { conf = new Config(); } GenericOptionsParser parser = new GenericOptionsParser(conf, args); LOG.info(conf.toString()); tool.setConf(conf); System.exit(tool.run(parser.getRemainingArgs())); } catch (ParseException e) { LOG.error("Error parsing generic options: {}", e.getMessage()); GenericOptionsParser.printGenericCommandUsage(System.err); System.exit(2); } catch (Exception e) { LOG.error("Error running tool", e); System.exit(1); } } }
void parseGeneralOptions(Options opts, Config conf, String[] args) throws ParseException { opts = buildGeneralOptions(opts); CommandLineParser parser = new GnuParser(); commandLine = parser.parse(opts, args, true); processGeneralOptions(conf, commandLine); }
public GenericOptionsParser(Config conf, Options options, String[] args) throws ParseException { this.conf = conf; parseGeneralOptions(options, conf, args); }
@Override public void process(Config conf, CommandLine commandLine) throws ParseException { try { List<File> jarFiles = validateFiles(commandLine.getOptionValue("libjars")); Map<String, String> jars = new HashMap<>(jarFiles.size()); List<String> names = new ArrayList<>(jarFiles.size()); for (File f : jarFiles) { jars.put(f.getName(), f.getAbsolutePath()); names.add(f.getName()); } conf.put(TOPOLOGY_LIB_PATH, jars); conf.put(TOPOLOGY_LIB_NAME, names); } catch (IOException e) { throw new ParseException(e.getMessage()); } } }
@Override public void process(Config conf, CommandLine commandLine) throws ParseException { try { List<File> jarFiles = validateFiles(commandLine.getOptionValue("libjars")); Map<String, String> jars = new HashMap<String, String>(jarFiles.size()); List<String> names = new ArrayList<String>(jarFiles.size()); for (File f : jarFiles) { jars.put(f.getName(), f.getAbsolutePath()); names.add(f.getName()); } conf.put(TOPOLOGY_LIB_PATH, jars); conf.put(TOPOLOGY_LIB_NAME, names); } catch (IOException e) { throw new ParseException(e.getMessage()); } } }
public static void run(Config conf, Tool tool, String[] args) { try { if (conf == null) { conf = new Config(); } GenericOptionsParser parser = new GenericOptionsParser(conf, args); LOG.info(conf.toString()); tool.setConf(conf); System.exit(tool.run(parser.getRemainingArgs())); } catch (ParseException e) { LOG.error("Error parsing generic options: {}", e.getMessage()); GenericOptionsParser.printGenericCommandUsage(System.err); System.exit(2); } catch (Exception e) { LOG.error("Error running tool", e); System.exit(1); } } }
void parseGeneralOptions(Options opts, Config conf, String[] args) throws ParseException { opts = buildGeneralOptions(opts); CommandLineParser parser = new GnuParser(); commandLine = parser.parse(opts, args, true); processGeneralOptions(conf, commandLine); }
public GenericOptionsParser(Config conf, Options options, String[] args) throws ParseException { this.conf = conf; parseGeneralOptions(options, conf, args); }