List of usage examples for org.apache.commons.cli CommandLine getOptionProperties
public Properties getOptionProperties(String opt)
From source file:com.cloudera.ByteCount.java
public static void main(String[] args) throws Exception { JobConf conf = new JobConf(new Configuration()); // Trim off the hadoop-specific args String[] remArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); // Pull in properties Options options = new Options(); Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator() .withDescription("use value for given property").create("D"); options.addOption(property);/*ww w .j a v a2s . com*/ Option skipChecksums = new Option("skipChecksums", "skip checksums"); options.addOption(skipChecksums); Option profile = new Option("profile", "profile tasks"); options.addOption(profile); CommandLineParser parser = new BasicParser(); CommandLine line = parser.parse(options, remArgs); Properties properties = line.getOptionProperties("D"); for (Entry<Object, Object> prop : properties.entrySet()) { conf.set(prop.getKey().toString(), prop.getValue().toString()); System.out.println("Set config key " + prop.getKey() + " to " + prop.getValue()); } if (line.hasOption("skipChecksums")) { conf.setBoolean("bytecount.skipChecksums", true); System.out.println("Skipping checksums"); } if (line.hasOption("profile")) { conf.setBoolean("mapred.task.profile", true); conf.set("mapred.task.profile.params", "-agentlib:hprof=cpu=samples,depth=100,interval=1ms,lineno=y,thread=y,file=%s"); conf.set(MRJobConfig.NUM_MAP_PROFILES, "0"); conf.set("mapred.task.profile.maps", "1"); System.out.println("Profiling map tasks"); } // Get the positional arguments out remArgs = line.getArgs(); if (remArgs.length != 2) { System.err.println("Usage: ByteCount <inputBase> <outputBase>"); System.exit(1); } String inputBase = remArgs[0]; String outputBase = remArgs[1]; Job job = Job.getInstance(conf); job.setInputFormatClass(ByteBufferInputFormat.class); job.setMapOutputKeyClass(ByteWritable.class); job.setMapOutputValueClass(LongWritable.class); job.setMapperClass(ByteCountMapper.class); job.setReducerClass(ByteCountReducer.class); job.setCombinerClass(ByteCountReducer.class); job.setOutputKeyClass(ByteWritable.class); job.setOutputValueClass(LongWritable.class); FileInputFormat.addInputPath(job, new Path(inputBase)); FileOutputFormat.setOutputPath(job, new Path(outputBase)); job.setJarByClass(ByteCount.class); boolean success = job.waitForCompletion(true); Counters counters = job.getCounters(); System.out.println("\tRead counters"); printCounter(counters, READ_COUNTER.BYTES_READ); printCounter(counters, READ_COUNTER.LOCAL_BYTES_READ); printCounter(counters, READ_COUNTER.SCR_BYTES_READ); printCounter(counters, READ_COUNTER.ZCR_BYTES_READ); System.exit(success ? 0 : 1); }
From source file:edu.hku.sdb.driver.SdbDriver.java
/** * @param args/*from w ww . j a v a2 s . c o m*/ */ public static void main(String[] args) { CommandLine line = parseAndValidateInput(args); String confDir = line.getOptionValue(CONF); Properties properties = line.getOptionProperties("D"); File sdbConnectionConfigFile = new File(confDir + "/" + ConnectionConf.CONF_FILE); File sdbServerConfigFile = new File(confDir + "/" + ServerConf.CONF_FILE); File sdbMetadbConfigFile = new File(confDir + "/" + MetadbConf.CONF_FILE); XMLPropParser propParser = new XMLPropParser(); // Parse all the sdb connection config Map<String, String> prop = propParser.importXML(sdbConnectionConfigFile); // Parse all the server config prop.putAll(propParser.importXML(sdbServerConfigFile)); // Parse all the metadb config prop.putAll(propParser.importXML(sdbMetadbConfigFile)); // Override the config if any Set<Object> states = properties.keySet(); // get set-view of keys for (Object object : states) { String key = (String) object; String value = properties.getProperty(key); prop.put(key, value); } // Cet log4j config PropertyConfigurator.configure(confDir + "/" + "log4j.properties"); ServerConf serverConf = ServerConfFactory.getServerConf(prop); MetadbConf metadbConf = MetadbConfFactory.getMetadbConf(prop); ConnectionConf connectionConf = new ConnectionConf(prop); SdbConf sdbConf = new SdbConf(connectionConf, serverConf, metadbConf); // Start the SDB proxy startConnectionPool(sdbConf); }
From source file:de.onyxbits.raccoon.cli.Router.java
public static void main(String[] args) { Options options = new Options(); Option property = Option.builder("D").argName("property=value").numberOfArgs(2).valueSeparator() .desc(Messages.getString(DESC + "D")).build(); options.addOption(property);/*w w w .j a va2s. c o m*/ Option help = new Option("h", "help", false, Messages.getString(DESC + "h")); options.addOption(help); Option version = new Option("v", "version", false, Messages.getString(DESC + "v")); options.addOption(version); // GPA: Google Play Apps (we might add different markets later) Option playAppDetails = new Option(null, "gpa-details", true, Messages.getString(DESC + "gpa-details")); playAppDetails.setArgName("package"); options.addOption(playAppDetails); Option playAppBulkDetails = new Option(null, "gpa-bulkdetails", true, Messages.getString(DESC + "gpa-bulkdetails")); playAppBulkDetails.setArgName("file"); options.addOption(playAppBulkDetails); Option playAppBatchDetails = new Option(null, "gpa-batchdetails", true, Messages.getString(DESC + "gpa-batchdetails")); playAppBatchDetails.setArgName("file"); options.addOption(playAppBatchDetails); Option playAppSearch = new Option(null, "gpa-search", true, Messages.getString(DESC + "gpa-search")); playAppSearch.setArgName("query"); options.addOption(playAppSearch); CommandLine commandLine = null; try { commandLine = new DefaultParser().parse(options, args); } catch (ParseException e) { System.err.println(e.getMessage()); System.exit(1); } if (commandLine.hasOption(property.getOpt())) { System.getProperties().putAll(commandLine.getOptionProperties(property.getOpt())); } if (commandLine.hasOption(help.getOpt())) { new HelpFormatter().printHelp("raccoon", Messages.getString("header"), options, Messages.getString("footer"), true); System.exit(0); } if (commandLine.hasOption(version.getOpt())) { System.out.println(GlobalsProvider.getGlobals().get(Version.class)); System.exit(0); } if (commandLine.hasOption(playAppDetails.getLongOpt())) { Play.details(commandLine.getOptionValue(playAppDetails.getLongOpt())); System.exit(0); } if (commandLine.hasOption(playAppBulkDetails.getLongOpt())) { Play.bulkDetails(new File(commandLine.getOptionValue(playAppBulkDetails.getLongOpt()))); System.exit(0); } if (commandLine.hasOption(playAppBatchDetails.getLongOpt())) { Play.details(new File(commandLine.getOptionValue(playAppBatchDetails.getLongOpt()))); System.exit(0); } if (commandLine.hasOption(playAppSearch.getLongOpt())) { Play.search(commandLine.getOptionValue(playAppSearch.getLongOpt())); System.exit(0); } }
From source file:com.commonsware.android.gcm.cmd.GCM.java
@SuppressWarnings("static-access") public static void main(String[] args) { Option helpOpt = new Option("h", "help", false, "print this message"); Option apiKeyOpt = OptionBuilder.withArgName("key").hasArg().isRequired().withDescription("GCM API key") .withLongOpt("apiKey").create('a'); Option deviceOpt = OptionBuilder.withArgName("regId").hasArg().isRequired() .withDescription("device to send to").withLongOpt("device").create('d'); Option dataOpt = OptionBuilder.withArgName("key=value").hasArgs(2).withDescription("datum to send") .withValueSeparator().withLongOpt("data").create('D'); Options options = new Options(); options.addOption(apiKeyOpt);/*from www . j av a2s . c o m*/ options.addOption(deviceOpt); options.addOption(dataOpt); options.addOption(helpOpt); CommandLineParser parser = new PosixParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption('h') || !line.hasOption('a') || !line.hasOption('d')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("gcm", options, true); } else { sendMessage(line.getOptionValue('a'), Arrays.asList(line.getOptionValues('d')), line.getOptionProperties("data")); } } catch (org.apache.commons.cli.MissingOptionException moe) { System.err.println("Invalid command syntax"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("gcm", options, true); } catch (Exception e) { e.printStackTrace(); } }
From source file:ca.uhn.hunit.example.MllpHl7v2MessageSwapper.java
public static void main(String[] theArgs) { Options options = new Options(); Option option = new Option("R", true, "Text to substiture in the message"); option.setArgs(2);/*www .j a v a 2s . c o m*/ option.setArgName("text=substitution"); option.setValueSeparator('='); option.setRequired(true); options.addOption(option); option = new Option("p", true, "Number of passes"); option.setValueSeparator('='); option.setRequired(false); options.addOption(option); CommandLine commandLine; int passes; try { commandLine = new PosixParser().parse(options, theArgs); passes = Integer.parseInt(commandLine.getOptionValue("p", "1")); } catch (ParseException e) { HelpFormatter hf = new HelpFormatter(); hf.printHelp( "java -cp hunit-[version]-jar-with-dependencies.jar ca.uhn.hunit.example.MllpHl7v2MessageSwapper {-Rtext=substitution}... [options]", options); return; } Properties substitutions = commandLine.getOptionProperties("R"); new MllpHl7v2MessageSwapper(true, substitutions, passes).run(); }
From source file:de.iew.imageread.Main.java
public static void main(String[] argv) { Options options = setupOptions();/*from w ww. j ava2 s . com*/ try { CommandLine cmd = parseOptions(options, argv); printHelp(options); if (cmd.hasOption("h")) { printHelp(options); return; } Main main = new Main(); if (cmd.hasOption("o")) { main.setImageOutputDir(cmd.getOptionValue("o")); } if (cmd.hasOption("q")) { Properties properties = cmd.getOptionProperties("q"); main.setQueryFilter(properties); } if (cmd.hasOption("mh")) { main.setMongohost(cmd.getOptionValue("mh")); } if (cmd.hasOption("mp")) { main.setMongoport(Integer.parseInt(cmd.getOptionValue("mp"))); } if (cmd.hasOption("md")) { main.setMongodb(cmd.getOptionValue("md")); } if (cmd.hasOption("g")) { main.setGroupingOutputOption(OUTPUT_OPTION.valueOf(cmd.getOptionValue("g"))); } if (cmd.hasOption("p")) { main.setImageFileNamePrefix(cmd.getOptionValue("p")); } main.printConfiguration(); main.run(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.twitter.heron.apiserver.Runtime.java
@SuppressWarnings({ "IllegalCatch", "RegexpSinglelineJava" }) public static void main(String[] args) throws Exception { final Options options = createOptions(); final Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); // parse the help options first. CommandLine cmd = parser.parse(helpOptions, args, true); if (cmd.hasOption(Flag.Help.name)) { usage(options);//from ww w . ja va 2 s. c om return; } try { cmd = parser.parse(options, args); } catch (ParseException pe) { System.err.println(pe.getMessage()); usage(options); return; } final boolean verbose = isVerbose(cmd); // set and configure logging level Logging.setVerbose(verbose); Logging.configure(verbose); LOG.debug("apiserver overrides:\n {}", cmd.getOptionProperties(Flag.Property.name)); final String toolsHome = getToolsHome(); // read command line flags final String cluster = cmd.getOptionValue(Flag.Cluster.name); final String heronConfigurationDirectory = getConfigurationDirectory(toolsHome, cmd); final String heronDirectory = getHeronDirectory(cmd); final String releaseFile = getReleaseFile(toolsHome, cmd); final String configurationOverrides = loadOverrides(cmd); final int port = getPort(cmd); final String downloadHostName = getDownloadHostName(cmd); final String heronCorePackagePath = getHeronCorePackagePath(cmd); final Config baseConfiguration = ConfigUtils.getBaseConfiguration(heronDirectory, heronConfigurationDirectory, releaseFile, configurationOverrides); final ResourceConfig config = new ResourceConfig(Resources.get()); final Server server = new Server(port); final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); contextHandler.setContextPath("/"); LOG.info("using configuration path: {}", heronConfigurationDirectory); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CLUSTER, cluster); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION, baseConfiguration); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION_DIRECTORY, heronConfigurationDirectory); contextHandler.setAttribute(HeronResource.ATTRIBUTE_CONFIGURATION_OVERRIDE_PATH, configurationOverrides); contextHandler.setAttribute(HeronResource.ATTRIBUTE_PORT, String.valueOf(port)); contextHandler.setAttribute(HeronResource.ATTRIBUTE_DOWNLOAD_HOSTNAME, Utils.isNotEmpty(downloadHostName) ? String.valueOf(downloadHostName) : null); contextHandler.setAttribute(HeronResource.ATTRIBUTE_HERON_CORE_PACKAGE_PATH, Utils.isNotEmpty(heronCorePackagePath) ? String.valueOf(heronCorePackagePath) : null); server.setHandler(contextHandler); final ServletHolder apiServlet = new ServletHolder(new ServletContainer(config)); contextHandler.addServlet(apiServlet, API_BASE_PATH); try { server.start(); LOG.info("Heron apiserver started at {}", server.getURI()); server.join(); } catch (Exception ex) { final String message = getErrorMessage(server, port, ex); LOG.error(message); System.err.println(message); System.exit(1); } finally { server.destroy(); } }
From source file:com.evolveum.midpoint.testing.model.client.sample.RunScript.java
/** * @param args/*from ww w . j av a 2s. c o m*/ */ public static void main(String[] args) { try { Options options = new Options(); options.addOption(OPT_HELP, "help", false, "Print this help information"); options.addOption(OPT_SCRIPT, "script", true, "Script file (XML for the moment)"); options.addOption(OPT_URL, true, "Endpoint URL (default: " + DEFAULT_ENDPOINT_URL + ")"); options.addOption(OPT_USER, "user", true, "User name (default: " + ADM_USERNAME + ")"); options.addOption(OPT_PASSWORD, "password", true, "Password"); options.addOption(OPT_FILE_FOR_DATA, "file-for-data", true, "Name of the file to write resulting XML data into"); options.addOption(OPT_FILE_FOR_CONSOLE, "file-for-console", true, "Name of the file to write resulting console output into"); options.addOption(OPT_FILE_FOR_RESULT, "file-for-result", true, "Name of the file to write operation result into"); options.addOption(OPT_HIDE_DATA, "hide-data", false, "Don't display data output"); options.addOption(OPT_HIDE_SCRIPT, "hide-script", false, "Don't display input script"); options.addOption(OPT_HIDE_CONSOLE, "hide-console", false, "Don't display console output"); options.addOption(OPT_HIDE_RESULT, "hide-result", false, "Don't display detailed operation result (default: showing if not SUCCESS)"); options.addOption(OPT_SHOW_RESULT, "show-result", false, "Always show detailed operation result (default: showing if not SUCCESS)"); options.addOption(OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator() .withDescription("use value for given property").create("D")); CommandLineParser parser = new GnuParser(); CommandLine cmdline = parser.parse(options, args); if (!cmdline.hasOption(OPT_SCRIPT) || cmdline.hasOption("h")) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp("runscript", options); System.exit(0); } ExecuteScriptsType request = new ExecuteScriptsType(); String script = readXmlFile(cmdline.getOptionValue(OPT_SCRIPT)); script = replaceParameters(script, cmdline.getOptionProperties("D")); request.setMslScripts(script); // todo fix this hack ExecuteScriptsOptionsType optionsType = new ExecuteScriptsOptionsType(); optionsType.setOutputFormat(OutputFormatType.MSL); // todo fix this hack request.setOptions(optionsType); if (!cmdline.hasOption(OPT_HIDE_SCRIPT)) { System.out.println("\nScript to execute:\n" + script); } System.out.println("================================================================="); ModelPortType modelPort = createModelPort(cmdline); ExecuteScriptsResponseType response = modelPort.executeScripts(request); System.out.println("================================================================="); for (SingleScriptOutputType output : response.getOutputs().getOutput()) { if (!cmdline.hasOption(OPT_HIDE_DATA)) { System.out.println("Data:\n" + output.getMslData()); System.out.println("-----------------------------------------------------------------"); } if (cmdline.hasOption(OPT_FILE_FOR_DATA)) { IOUtils.write(output.getMslData(), new FileOutputStream(cmdline.getOptionValue(OPT_FILE_FOR_DATA)), "UTF-8"); } if (!cmdline.hasOption(OPT_HIDE_CONSOLE)) { System.out.println("Console output:\n" + output.getTextOutput()); } if (cmdline.hasOption(OPT_HIDE_CONSOLE)) { IOUtils.write(output.getMslData(), new FileWriter(cmdline.getOptionValue(OPT_FILE_FOR_CONSOLE))); } } System.out.println("================================================================="); System.out.println("Operation result: " + getResultStatus(response.getResult())); if (!cmdline.hasOption(OPT_HIDE_RESULT) && (cmdline.hasOption(OPT_SHOW_RESULT) || response.getResult() == null || response.getResult().getStatus() != OperationResultStatusType.SUCCESS)) { System.out.println("\n\n" + marshalResult(response.getResult())); } if (cmdline.hasOption(OPT_FILE_FOR_RESULT)) { IOUtils.write(marshalResult(response.getResult()), new FileWriter(cmdline.getOptionValue(OPT_FILE_FOR_RESULT))); } } catch (Exception e) { e.printStackTrace(); System.exit(-1); } }
From source file:com.fiveclouds.jasper.JasperRunner.java
public static void main(String[] args) { // Set-up the options for the utility Options options = new Options(); Option report = new Option("report", true, "jasper report to run (i.e. /path/to/report.jrxml)"); options.addOption(report);/* w w w . jav a2 s. c o m*/ Option driver = new Option("driver", true, "the jdbc driver class (i.e. com.mysql.jdbc.Driver)"); driver.setRequired(true); options.addOption(driver); options.addOption("jdbcurl", true, "database jdbc url (i.e. jdbc:mysql://localhost:3306/database)"); options.addOption("excel", true, "Will override the PDF default and export to Microsoft Excel"); options.addOption("username", true, "database username"); options.addOption("password", true, "database password"); options.addOption("output", true, "the output filename (i.e. path/to/report.pdf"); options.addOption("help", false, "print this message"); Option propertyOption = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator() .withDescription("use value as report property").create("D"); options.addOption(propertyOption); // Parse the options and build the report CommandLineParser parser = new PosixParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("jasper-runner", options); } else { System.out.println("Building report " + cmd.getOptionValue("report")); try { Class.forName(cmd.getOptionValue("driver")); Connection connection = DriverManager.getConnection(cmd.getOptionValue("jdbcurl"), cmd.getOptionValue("username"), cmd.getOptionValue("password")); System.out.println("Connected to " + cmd.getOptionValue("jdbcurl")); JasperReport jasperReport = JasperCompileManager.compileReport(cmd.getOptionValue("report")); JRPdfExporter pdfExporter = new JRPdfExporter(); Properties properties = cmd.getOptionProperties("D"); Map<String, Object> parameters = new HashMap<String, Object>(); Map<String, JRParameter> reportParameters = new HashMap<String, JRParameter>(); for (JRParameter param : jasperReport.getParameters()) { reportParameters.put(param.getName(), param); } for (Object propertyKey : properties.keySet()) { String parameterName = String.valueOf(propertyKey); String parameterValue = String.valueOf(properties.get(propertyKey)); JRParameter reportParam = reportParameters.get(parameterName); if (reportParam != null) { if (reportParam.getValueClass().equals(String.class)) { System.out.println( "Property " + parameterName + " set to String = " + parameterValue); parameters.put(parameterName, parameterValue); } else if (reportParam.getValueClass().equals(Integer.class)) { System.out.println( "Property " + parameterName + " set to Integer = " + parameterValue); parameters.put(parameterName, Integer.parseInt(parameterValue)); } else { System.err.print("Unsupported type for property " + parameterName); System.exit(1); } } else { System.out.println("Property " + parameterName + " not found in the report! IGNORING"); } } JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, connection); pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, print); pdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, cmd.getOptionValue("output")); System.out.println("Exporting report to " + cmd.getOptionValue("output")); pdfExporter.exportReport(); } catch (JRException e) { System.err.print("Unable to parse report file (" + cmd.getOptionValue("r") + ")"); e.printStackTrace(); System.exit(1); } catch (ClassNotFoundException e) { System.err.print("Unable to find the database driver, is it on the classpath?"); e.printStackTrace(); System.exit(1); } catch (SQLException e) { System.err.print("An SQL exception has occurred (" + e.getMessage() + ")"); e.printStackTrace(); System.exit(1); } } } catch (ParseException e) { System.err.print("Unable to parse command line options (" + e.getMessage() + ")"); System.exit(1); } }
From source file:edu.osu.ling.pep.Pep.java
/** * Invokes Pep from the command line.//from w w w .ja v a 2 s. c o m * <p> * The main work this method does, apart from tokenizing the arguments and * input tokens, is to load and parse the XML grammar file (as specified by * <code>-g</code> or <code>--grammar</code>). If any of the arguments * <code>-g</code>, <code>--grammar</code>, <code>-s</code>, * <code>--seed</code>, <code>-o</code>, <code>--option</code>, occur with * no argument following, this method prints an error notifying the user. * * @param args * The expected arguments are as follows, and can occur in any * particular order: * <ul> * <li><code>-g|--grammar <grammar file></code></li> <li> * <code>-s|--seed <seed category></code></li> <li><code> * -v|--verbose {verbosity level}</code></li> <li><code> * -o|--option <OPTION_NAME=value></code></li> <li><code> * -h|--help (prints usage information)</code></li> <li><code> * <token1 ... token<em>n</em>></code> (or <code>-</code> * for standard input)</li> * </ul> * <code>OPTION_NAME</code> must be the name of one of the * recognized {@link ParserOption options}. If <code>-h</code> or * <code>--help</code> occur anywhere in the arguments, usage * information is printed and no parsing takes place. */ @SuppressWarnings("static-access") public static final void main(final String[] args) { try { final Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("grammar").withDescription("the grammar to use").hasArg() .isRequired().withArgName("grammar file").create('g')); opts.addOption(OptionBuilder.withLongOpt("seed").withDescription("the seed category to parse for") .hasArg().isRequired().withArgName("seed category").create('s')); opts.addOption(OptionBuilder.withLongOpt("verbose").withDescription("0-3").hasOptionalArg() .withArgName("verbosity level").create('v')); opts.addOption(OptionBuilder.withLongOpt("option").withDescription("sets parser options") .withArgName("OPTION=value").hasArgs(2).withValueSeparator() .withDescription("use value for given property").create("o")); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("prints this message").create('h')); final CommandLineParser parser = new GnuParser(); try { final CommandLine line = parser.parse(opts, args); if (line.hasOption('h')) { Pep.printHelp(opts); } else { final int v = Integer.parseInt(line.getOptionValue('v', Integer.toString(Pep.V_PARSE))); if (v < 0) { throw new PepException("verbosity < 0: " + v); } Pep.verbosity = v; final Map<ParserOption, Boolean> options = new EnumMap<ParserOption, Boolean>( ParserOption.class); final Properties props = line.getOptionProperties("o"); for (final Object key : props.keySet()) { try { options.put(ParserOption.valueOf(key.toString()), Boolean.valueOf(props.get(key).toString())); } catch (final IllegalArgumentException iae) { Pep.printError("no option named " + key.toString()); Pep.printHelp(opts); return; } } final Pep pep = new Pep(options); // final Grammar grammar = // new GrammarParser(Pep.findGrammar(line // .getOptionValue('g'))).t.parse(); final List<?> ts = line.getArgList(); List<String> tokens = null; if (ts.isEmpty() || ts.get(0).equals("-")) { tokens = Pep.readTokens(new Scanner(System.in)); } else { tokens = new ArrayList<String>(ts.size()); for (final Object t : ts) { tokens.add(t.toString()); } } pep.lastParseStart = System.currentTimeMillis(); // try { // pep.parse(grammar, tokens, // new Category(line.getOptionValue('s'))); // } catch (final PepException ignore) { // // ignore here, we're listening // } } } catch (final ParseException pe) { Pep.printError("command-line syntax problem: " + pe.getMessage()); Pep.printHelp(opts); } } catch (final PepException pe) { final Throwable cause = pe.getCause(); Pep.printError((cause == null) ? pe : cause); } catch (final RuntimeException re) { Pep.printError(re); } }