List of usage examples for org.apache.commons.cli PosixParser PosixParser
PosixParser
From source file:com.opengamma.batch.BatchJobRunner.java
/** * Creates an runs a batch job based on a properties file and configuration. *///from ww w . j a v a 2 s . c o m public static void main(String[] args) throws Exception { // CSIGNORE if (args.length == 0) { usage(); System.exit(-1); } CommandLine line = null; Properties configProperties = null; final String propertyFile = "batchJob.properties"; String configPropertyFile = null; if (System.getProperty(propertyFile) != null) { configPropertyFile = System.getProperty(propertyFile); try { FileInputStream fis = new FileInputStream(configPropertyFile); configProperties = new Properties(); configProperties.load(fis); fis.close(); } catch (FileNotFoundException e) { s_logger.error("The system cannot find " + configPropertyFile); System.exit(-1); } } else { try { FileInputStream fis = new FileInputStream(propertyFile); configProperties = new Properties(); configProperties.load(fis); fis.close(); configPropertyFile = propertyFile; } catch (FileNotFoundException e) { // there is no config file so we expect command line arguments try { CommandLineParser parser = new PosixParser(); line = parser.parse(getOptions(), args); } catch (ParseException e2) { usage(); System.exit(-1); } } } RunCreationMode runCreationMode = getRunCreationMode(line, configProperties, configPropertyFile); if (runCreationMode == null) { // default runCreationMode = RunCreationMode.AUTO; } String engineURI = getProperty("engineURI", line, configProperties, configPropertyFile); String brokerURL = getProperty("brokerURL", line, configProperties, configPropertyFile); Instant valuationTime = getValuationTime(line, configProperties, configPropertyFile); LocalDate observationDate = getObservationDate(line, configProperties, configPropertyFile); UniqueId viewDefinitionUniqueId = getViewDefinitionUniqueId(line, configProperties); URI vpBase; try { vpBase = new URI(engineURI); } catch (URISyntaxException ex) { throw new OpenGammaRuntimeException("Invalid URI", ex); } ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(brokerURL); activeMQConnectionFactory.setWatchTopicAdvisories(false); JmsConnectorFactoryBean jmsConnectorFactoryBean = new JmsConnectorFactoryBean(); jmsConnectorFactoryBean.setConnectionFactory(activeMQConnectionFactory); jmsConnectorFactoryBean.setName("Masters"); JmsConnector jmsConnector = jmsConnectorFactoryBean.getObjectCreating(); ScheduledExecutorService heartbeatScheduler = Executors.newSingleThreadScheduledExecutor(); try { ViewProcessor vp = new RemoteViewProcessor(vpBase, jmsConnector, heartbeatScheduler); ViewClient vc = vp.createViewClient(UserPrincipal.getLocalUser()); HistoricalMarketDataSpecification marketDataSpecification = MarketData.historical(observationDate, null); ViewExecutionOptions executionOptions = ExecutionOptions.batch(valuationTime, marketDataSpecification, null); vc.attachToViewProcess(viewDefinitionUniqueId, executionOptions); vc.waitForCompletion(); } finally { heartbeatScheduler.shutdown(); } }
From source file:com.genentech.chemistry.openEye.apps.SDFMDLSSSMatcher.java
public static void main(String... args) throws IOException, InterruptedException { oechem.OEUseJavaHeap(false);//www . j a va 2 s .c o m // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file [.sdf,...]"); opt.setRequired(true); options.addOption(opt); opt = new Option("out", true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); opt = new Option("ref", true, "refrence file with MDL query molecules"); opt.setRequired(true); options.addOption(opt); opt = new Option("anyMatch", false, "if set all matches are reported not just the first."); opt.setRequired(false); options.addOption(opt); opt = new Option("printAll", false, "if set even compounds that do not macht are outputted."); opt.setRequired(false); options.addOption(opt); opt = new Option("nCpu", true, "number of CPU's used in parallel, dafault 1"); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (args.length > 0) { exitWithHelp("Unknown param: " + args[0], options); } if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } int nCpu = 1; boolean firstMatch = !cmd.hasOption("anyMatch"); boolean printAll = cmd.hasOption("printAll"); String d = cmd.getOptionValue("nCpu"); if (d != null) nCpu = Integer.parseInt(d); String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); String refFile = cmd.getOptionValue("ref"); SDFMDLSSSMatcher matcher = new SDFMDLSSSMatcher(refFile, outFile, firstMatch, printAll, nCpu); matcher.run(inFile); matcher.close(); }
From source file:edu.msu.cme.rdp.classifier.ClassifierCmd.java
/** * This is the main method to do classification. * <p>Usage: java ClassifierCmd queryFile outputFile [property file]. * <br>/* w ww .j a v a 2s. c o m*/ * queryFile can be one of the following formats: Fasta, Genbank and EMBL. * <br> * outputFile will be used to save the classification output. * <br> * property file contains the mapping of the training files. * <br> * Note: the training files and the property file should be in the same directory. * The default property file is set to data/classifier/16srrna/rRNAClassifier.properties. */ public static void main(String[] args) throws Exception { String queryFile = null; String outputFile = null; String propFile = null; String gene = null; ClassificationResultFormatter.FORMAT format = CmdOptions.DEFAULT_FORMAT; int min_bootstrap_words = Classifier.MIN_BOOTSTRSP_WORDS; try { CommandLine line = new PosixParser().parse(options, args); if (line.hasOption(CmdOptions.OUTFILE_SHORT_OPT)) { outputFile = line.getOptionValue(CmdOptions.OUTFILE_SHORT_OPT); } else { throw new Exception("outputFile must be specified"); } if (line.hasOption(CmdOptions.TRAINPROPFILE_SHORT_OPT)) { if (gene != null) { throw new IllegalArgumentException( "Already specified the gene from the default location. Can not specify train_propfile"); } else { propFile = line.getOptionValue(CmdOptions.TRAINPROPFILE_SHORT_OPT); } } if (line.hasOption(CmdOptions.FORMAT_SHORT_OPT)) { String f = line.getOptionValue(CmdOptions.FORMAT_SHORT_OPT); if (f.equalsIgnoreCase("allrank")) { format = ClassificationResultFormatter.FORMAT.allRank; } else if (f.equalsIgnoreCase("fixrank")) { format = ClassificationResultFormatter.FORMAT.fixRank; } else if (f.equalsIgnoreCase("filterbyconf")) { format = ClassificationResultFormatter.FORMAT.filterbyconf; } else if (f.equalsIgnoreCase("db")) { format = ClassificationResultFormatter.FORMAT.dbformat; } else { throw new IllegalArgumentException( "Not valid output format, only allrank, fixrank, filterbyconf and db allowed"); } } if (line.hasOption(CmdOptions.GENE_SHORT_OPT)) { if (propFile != null) { throw new IllegalArgumentException( "Already specified train_propfile. Can not specify gene any more"); } gene = line.getOptionValue(CmdOptions.GENE_SHORT_OPT).toLowerCase(); if (!gene.equals(ClassifierFactory.RRNA_16S_GENE) && !gene.equals(ClassifierFactory.FUNGALLSU_GENE)) { throw new IllegalArgumentException(gene + " is NOT valid, only allows " + ClassifierFactory.RRNA_16S_GENE + " and " + ClassifierFactory.FUNGALLSU_GENE); } } if (line.hasOption(CmdOptions.MIN_BOOTSTRAP_WORDS_SHORT_OPT)) { min_bootstrap_words = Integer .parseInt(line.getOptionValue(CmdOptions.MIN_BOOTSTRAP_WORDS_SHORT_OPT)); if (min_bootstrap_words < Classifier.MIN_BOOTSTRSP_WORDS) { throw new IllegalArgumentException(CmdOptions.MIN_BOOTSTRAP_WORDS_LONG_OPT + " must be at least " + Classifier.MIN_BOOTSTRSP_WORDS); } } args = line.getArgs(); if (args.length != 1) { throw new Exception("Expect one query file"); } queryFile = args[0]; } catch (Exception e) { System.out.println("Command Error: " + e.getMessage()); new HelpFormatter().printHelp(120, "ClassifierCmd [options] <samplefile>\nNote this is the legacy command for one sample classification ", "", options, ""); return; } if (propFile == null && gene == null) { gene = CmdOptions.DEFAULT_GENE; } ClassifierCmd classifierCmd = new ClassifierCmd(); printLicense(); classifierCmd.doClassify(queryFile, outputFile, propFile, format, gene, min_bootstrap_words); }
From source file:edu.msu.cme.rdp.unifrac.Unifrac.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); CommandLine line = null;/*from w w w . j av a 2 s . co m*/ try { line = parser.parse(options, args); } catch (UnrecognizedOptionException e) { System.err.println(e.getMessage()); printUsage(); return; } UnifracTree unifracTree = null; PrintStream out = System.out; if (line.hasOption("tree") && line.hasOption("sequence-files")) { printUsage(); } else if (!(line.hasOption("weighted") || line.hasOption("unweighted") || line.hasOption("significance"))) { System.err.println("Must specify at least one calculation option"); printUsage(); } else if (line.hasOption("sample-mapping")) { Map<String, UnifracSample> sampleMap = readSampleMap(line.getOptionValue("sample-mapping")); if (line.hasOption("tree")) { unifracTree = parseNewickTree(line.getOptionValue("tree"), sampleMap); } } else { if (!line.hasOption("sample-mapping")) { System.err.println("A sample mapping file must be provided"); } printUsage(); } if (line.hasOption("outfile")) { out = new PrintStream(line.getOptionValue("outfile")); } if (unifracTree != null) { if (line.hasOption("unweighted")) { printResults(out, unifracTree.computeUnifrac(), "Unweighted Unifrac"); if (line.hasOption("significance")) { printResults(out, unifracTree.computeUnifracSig(1000, false), "Unweighted Unifrac Significance"); } } if (line.hasOption("weighted")) { printResults(out, unifracTree.computeWeightedUnifrac(), "Weighted Unifrac"); if (line.hasOption("significance")) { printResults(out, unifracTree.computeUnifracSig(1000, true), "Weighted Unifrac Significance"); } } } }
From source file:edu.msu.cme.rdp.multicompare.Main.java
public static void main(String[] args) throws Exception { PrintStream hier_out = null;//from ww w. j av a 2 s. c om PrintWriter assign_out = new PrintWriter(new NullWriter()); PrintStream bootstrap_out = null; File hier_out_filename = null; String propFile = null; File biomFile = null; File metadataFile = null; PrintWriter shortseq_out = null; List<MCSample> samples = new ArrayList(); ClassificationResultFormatter.FORMAT format = ClassificationResultFormatter.FORMAT.allRank; float conf = CmdOptions.DEFAULT_CONF; String gene = null; int min_bootstrap_words = Classifier.MIN_BOOTSTRSP_WORDS; try { CommandLine line = new PosixParser().parse(options, args); if (line.hasOption(CmdOptions.OUTFILE_SHORT_OPT)) { assign_out = new PrintWriter(line.getOptionValue(CmdOptions.OUTFILE_SHORT_OPT)); } else { throw new IllegalArgumentException("Require the output file for classification assignment"); } if (line.hasOption(CmdOptions.HIER_OUTFILE_SHORT_OPT)) { hier_out_filename = new File(line.getOptionValue(CmdOptions.HIER_OUTFILE_SHORT_OPT)); hier_out = new PrintStream(hier_out_filename); } if (line.hasOption(CmdOptions.BIOMFILE_SHORT_OPT)) { biomFile = new File(line.getOptionValue(CmdOptions.BIOMFILE_SHORT_OPT)); } if (line.hasOption(CmdOptions.METADATA_SHORT_OPT)) { metadataFile = new File(line.getOptionValue(CmdOptions.METADATA_SHORT_OPT)); } if (line.hasOption(CmdOptions.TRAINPROPFILE_SHORT_OPT)) { if (gene != null) { throw new IllegalArgumentException( "Already specified the gene from the default location. Can not specify train_propfile"); } else { propFile = line.getOptionValue(CmdOptions.TRAINPROPFILE_SHORT_OPT); } } if (line.hasOption(CmdOptions.FORMAT_SHORT_OPT)) { String f = line.getOptionValue(CmdOptions.FORMAT_SHORT_OPT); if (f.equalsIgnoreCase("allrank")) { format = ClassificationResultFormatter.FORMAT.allRank; } else if (f.equalsIgnoreCase("fixrank")) { format = ClassificationResultFormatter.FORMAT.fixRank; } else if (f.equalsIgnoreCase("filterbyconf")) { format = ClassificationResultFormatter.FORMAT.filterbyconf; } else if (f.equalsIgnoreCase("db")) { format = ClassificationResultFormatter.FORMAT.dbformat; } else if (f.equalsIgnoreCase("biom")) { format = ClassificationResultFormatter.FORMAT.biom; } else { throw new IllegalArgumentException( "Not an valid output format, only allrank, fixrank, biom, filterbyconf and db allowed"); } } if (line.hasOption(CmdOptions.GENE_SHORT_OPT)) { if (propFile != null) { throw new IllegalArgumentException( "Already specified train_propfile. Can not specify gene any more"); } gene = line.getOptionValue(CmdOptions.GENE_SHORT_OPT).toLowerCase(); if (!gene.equals(ClassifierFactory.RRNA_16S_GENE) && !gene.equals(ClassifierFactory.FUNGALLSU_GENE) && !gene.equals(ClassifierFactory.FUNGALITS_warcup_GENE) && !gene.equals(ClassifierFactory.FUNGALITS_unite_GENE)) { throw new IllegalArgumentException(gene + " not found, choose from" + ClassifierFactory.RRNA_16S_GENE + ", " + ClassifierFactory.FUNGALLSU_GENE + ", " + ClassifierFactory.FUNGALITS_warcup_GENE + ", " + ClassifierFactory.FUNGALITS_unite_GENE); } } if (line.hasOption(CmdOptions.MIN_BOOTSTRAP_WORDS_SHORT_OPT)) { min_bootstrap_words = Integer .parseInt(line.getOptionValue(CmdOptions.MIN_BOOTSTRAP_WORDS_SHORT_OPT)); if (min_bootstrap_words < Classifier.MIN_BOOTSTRSP_WORDS) { throw new IllegalArgumentException(CmdOptions.MIN_BOOTSTRAP_WORDS_LONG_OPT + " must be at least " + Classifier.MIN_BOOTSTRSP_WORDS); } } if (line.hasOption(CmdOptions.BOOTSTRAP_SHORT_OPT)) { String confString = line.getOptionValue(CmdOptions.BOOTSTRAP_SHORT_OPT); try { conf = Float.valueOf(confString); } catch (NumberFormatException e) { throw new IllegalArgumentException("Confidence must be a decimal number"); } if (conf < 0 || conf > 1) { throw new IllegalArgumentException("Confidence must be in the range [0,1]"); } } if (line.hasOption(CmdOptions.SHORTSEQ_OUTFILE_SHORT_OPT)) { shortseq_out = new PrintWriter(line.getOptionValue(CmdOptions.SHORTSEQ_OUTFILE_SHORT_OPT)); } if (line.hasOption(CmdOptions.BOOTSTRAP_OUTFILE_SHORT_OPT)) { bootstrap_out = new PrintStream(line.getOptionValue(CmdOptions.BOOTSTRAP_OUTFILE_SHORT_OPT)); } if (format.equals(ClassificationResultFormatter.FORMAT.biom) && biomFile == null) { throw new IllegalArgumentException("biom format requires an input biom file"); } if (biomFile != null) { // if input biom file provided, use biom format format = ClassificationResultFormatter.FORMAT.biom; } args = line.getArgs(); for (String arg : args) { String[] inFileNames = arg.split(","); File inputFile = new File(inFileNames[0]); File idmappingFile = null; if (!inputFile.exists()) { throw new IllegalArgumentException("Failed to find input file \"" + inFileNames[0] + "\""); } if (inFileNames.length == 2) { idmappingFile = new File(inFileNames[1]); if (!idmappingFile.exists()) { throw new IllegalArgumentException("Failed to find input file \"" + inFileNames[1] + "\""); } } MCSample nextSample = new MCSample(inputFile, idmappingFile); samples.add(nextSample); } if (propFile == null && gene == null) { gene = CmdOptions.DEFAULT_GENE; } if (samples.size() < 1) { throw new IllegalArgumentException("Require at least one sample files"); } } catch (Exception e) { System.out.println("Command Error: " + e.getMessage()); new HelpFormatter().printHelp(80, " [options] <samplefile>[,idmappingfile] ...", "", options, ""); return; } MultiClassifier multiClassifier = new MultiClassifier(propFile, gene, biomFile, metadataFile); MultiClassifierResult result = multiClassifier.multiCompare(samples, conf, assign_out, format, min_bootstrap_words); assign_out.close(); if (hier_out != null) { DefaultPrintVisitor printVisitor = new DefaultPrintVisitor(hier_out, samples); result.getRoot().topDownVisit(printVisitor); hier_out.close(); if (multiClassifier.hasCopyNumber()) { // print copy number corrected counts File cn_corrected_s = new File(hier_out_filename.getParentFile(), "cnadjusted_" + hier_out_filename.getName()); PrintStream cn_corrected_hier_out = new PrintStream(cn_corrected_s); printVisitor = new DefaultPrintVisitor(cn_corrected_hier_out, samples, true); result.getRoot().topDownVisit(printVisitor); cn_corrected_hier_out.close(); } } if (bootstrap_out != null) { for (MCSample sample : samples) { MCSamplePrintUtil.printBootstrapCountTable(bootstrap_out, sample); } bootstrap_out.close(); } if (shortseq_out != null) { for (String id : result.getBadSequences()) { shortseq_out.write(id + "\n"); } shortseq_out.close(); } }
From source file:eu.scape_project.tika_identify.TikaIdentification.java
public static void main(String[] args) throws ParseException, IOException, InterruptedException, ClassNotFoundException { CommandLineParser cmdParser = new PosixParser(); TikaCliOptions tikaCliOpts = new TikaCliOptions(); appConfig = new TikaCliConfig(); CommandLine cmd = cmdParser.parse(tikaCliOpts.options, args); if ((args.length == 0) || (cmd.hasOption(tikaCliOpts.HELP_OPT))) { tikaCliOpts.exit("Help", 0); } else {/*from w ww .ja v a 2 s. c om*/ tikaCliOpts.initOptions(cmd, appConfig); TikaIdentification tc = new TikaIdentification(); if (appConfig.isLocal()) { tc.startApplication(); } else { tc.startHadoopJob(); } } }
From source file:lee.util.jtap.JTapCli.java
/** * @param args//from w ww . ja va 2 s .com */ public static void main(String[] args) { Options options = constructOptions(); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println("Cmd Parsing Error: " + e.getMessage()); JTapCli.printHelp(options); } String resultMessage = "Done."; if (cmd.hasOption("dumpkeys")) { resultMessage = JTapCli.dumpKeys(); } else if (cmd.hasOption("dumpall")) { resultMessage = JTapCli.dumpAll(); } else if (cmd.hasOption("s") || cmd.hasOption("session")) { HashMap<String, String> argsMap = getMappedArgs(cmd, "host", "bucket", "password", "port"); resultMessage = ">> " + JTapCli.setSession(argsMap); } else if (cmd.hasOption("dk") || cmd.hasOption("deletekey")) { resultMessage = JTapCli.deleteKey(cmd.getOptionValues("dk")); } else if (cmd.hasOption("gk") || cmd.hasOption("getkey")) { resultMessage = JTapCli.dumpKey(cmd.getOptionValues("gk")); } else if (cmd.hasOption("cs") || cmd.hasOption("clearsession")) { boolean removed = JTapCli.session.delete(); if (removed) { System.out .println("Saved session data has been cleared. To set the values again call with -session"); } } else { JTapCli.printHelp(options); resultMessage = ""; } System.out.println(resultMessage); return; }
From source file:com.ottogroup.bi.spqr.websocket.server.SPQRWebSocketServer.java
/** * Checks the command-line settings and ramps up the server * @param args arguments passed from command-line * @throws ParseException indicates that parsing the command-line failed for any reason * @throws InterruptedException //from www.ja va 2 s.co m * @throws IOException */ public static void main(String[] args) throws ParseException, IOException, InterruptedException { //////////////////////////////////////////////////////////////////////// // evaluate command-line and ensure that it provides valid input CommandLineParser parser = new PosixParser(); CommandLine commandLine = parser.parse(getOptions(), args); if (commandLine.hasOption(CFG_HELP)) { new HelpFormatter().printHelp("spqr-websocket-server", getOptions()); return; } if (!commandLine.hasOption(CFG_CONFIGURATION_FILE)) { new HelpFormatter().printHelp("spqr-websocket-server", "", getOptions(), "Missing required configuration file"); return; } // //////////////////////////////////////////////////////////////////////// new SPQRWebSocketServer().run(commandLine.getOptionValue(CFG_CONFIGURATION_FILE)); }
From source file:LNISmokeTest.java
/** * Execute command line. See Usage string for options and arguments. * // w w w . jav a 2 s . com * @param argv the argv * * @throws Exception the exception */ public static void main(String[] argv) throws Exception { Options options = new Options(); OptionGroup func = new OptionGroup(); func.addOption(new Option("c", "copy", true, "copy <Item> to -C <Collection>")); func.addOption(new Option("s", "submit", true, "submit <collection> -P <packager> -i <file>")); func.addOption(new Option("d", "disseminate", true, "disseminate <item> -P <packager> -o <file>")); func.addOption(new Option("f", "propfind", true, "propfind of all properties or -N <propname>")); func.addOption(new Option("r", "rpropfind", true, "recursive propfind, only collections")); func.addOption(new Option("n", "names", true, "list all property names on resource")); func.addOption(new Option("p", "proppatch", true, "set property: <handle> -N <property> -V <newvalue>")); func.setRequired(true); options.addOptionGroup(func); options.addOption("h", "help", false, "show help message"); options.addOption("e", "endpoint", true, "SOAP endpoint URL (REQUIRED)"); options.addOption("P", "packager", true, "Packager to use to import/export a package."); options.addOption("C", "collection", true, "Target collection of -c copy"); options.addOption("o", "output", true, "file to create for new package"); options.addOption("i", "input", true, "file containing package to submit"); options.addOption("N", "name", true, "name of property to query/set"); options.addOption("V", "value", true, "new value for property being set"); try { CommandLine line = (new PosixParser()).parse(options, argv); if (line.hasOption("h")) { usage(options, 0, null); } // get SOAP client connection, using the endpoint URL String endpoint = line.getOptionValue("e"); if (endpoint == null) { usage(options, 2, "Missing the required -e endpoint argument"); } LNISoapServletServiceLocator loc = new LNISoapServletServiceLocator(); LNISoapServlet lni = loc.getDSpaceLNI(new URL(endpoint)); // propfind - with optional single-property Name if (line.hasOption("f")) { String pfXml = (line.hasOption("N")) ? specificPropPrefix + line.getOptionValue("N") + specificPropSuffix : allProp; doPropfind(lni, line.getOptionValue("f"), pfXml, 0, null); } // recursive propfind limited to collection, community objects else if (line.hasOption("r")) { doPropfind(lni, line.getOptionValue("r"), someProp, -1, "collection,community"); } else if (line.hasOption("n")) { doPropfind(lni, line.getOptionValue("n"), nameProp, 0, null); } else if (line.hasOption("p")) { if (line.hasOption("N") && line.hasOption("V")) { doProppatch(lni, line.getOptionValue("p"), line.getOptionValue("N"), line.getOptionValue("V")); } else { usage(options, 13, "Missing required args: -N <name> -V <value>n"); } } // submit a package else if (line.hasOption("s")) { if (line.hasOption("P") && line.hasOption("i")) { doPut(lni, line.getOptionValue("s"), line.getOptionValue("P"), line.getOptionValue("i"), endpoint); } else { usage(options, 13, "Missing required args after -s: -P <packager> -i <file>"); } } // Disseminate (GET) item as package else if (line.hasOption("d")) { if (line.hasOption("P") && line.hasOption("o")) { doGet(lni, line.getOptionValue("d"), line.getOptionValue("P"), line.getOptionValue("o"), endpoint); } else { usage(options, 13, "Missing required args after -d: -P <packager> -o <file>"); } } // copy from src to dst else if (line.hasOption("c")) { if (line.hasOption("C")) { doCopy(lni, line.getOptionValue("c"), line.getOptionValue("C")); } else { usage(options, 13, "Missing required args after -c: -C <collection>\n"); } } else { usage(options, 14, "Missing command option.\n"); } } catch (ParseException pe) { usage(options, 1, "Error in arguments: " + pe.toString()); } catch (java.rmi.RemoteException de) { System.out.println("ERROR, got RemoteException, message=" + de.getMessage()); de.printStackTrace(); die(1, " Exception class=" + de.getClass().getName()); } }
From source file:javadepchecker.Main.java
/** * @param args the command line arguments *///w w w. j a va 2 s.co m public static void main(String[] args) throws IOException { int exit = 0; try { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption("h", "help", false, "print help"); options.addOption("i", "image", true, "image directory"); options.addOption("v", "verbose", false, "print verbose output"); CommandLine line = parser.parse(options, args); String[] files = line.getArgs(); if (line.hasOption("h") || files.length == 0) { HelpFormatter h = new HelpFormatter(); h.printHelp("java-dep-check [-i <image] <package.env>+", options); } else { image = line.getOptionValue("i", ""); for (String arg : files) { if (line.hasOption('v')) System.out.println("Checking " + arg); if (!checkPkg(new File(arg))) { exit = 1; } } } } catch (ParseException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } System.exit(exit); }