List of usage examples for org.apache.commons.cli CommandLine getArgList
public List getArgList()
From source file:edu.ksu.cis.indus.tools.slicer.SliceXMLizerCLI.java
/** * Parses the command line argument./*from w w w . jav a 2 s . co m*/ * * @param args contains the command line arguments. * @param xmlizer used to xmlize the slice. * @pre args != null and xmlizer != null */ private static void parseCommandLine(final String[] args, final SliceXMLizerCLI xmlizer) { // create options final Options _options = new Options(); Option _o = new Option("c", "config-file", true, "The configuration file to use. If unspecified, uses default configuration file."); _o.setArgs(1); _o.setArgName("config-file"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("a", "active-config", true, "The alternate configuration to use instead of the one specified in the configuration."); _o.setArgs(1); _o.setArgName("config"); _o.setLongOpt("active-config"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("o", "output-dir", true, "The output directory to dump the generated info. If unspecified, picks a temporary directory."); _o.setArgs(1); _o.setArgName("path"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("g", "gui-config", false, "Display gui for configuration."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("p", "soot-classpath", true, "Prepend this to soot class path."); _o.setArgs(1); _o.setArgName("classpath"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("e", "exception-preserving-slice", true, "Generate slice that preserves every throw statement in " + "the application class. Comma-separated combination of optional arguments: inAppOnly - preserve throw " + "statements in application classes only, separateSlices - generated a different slice for each throw " + "statement. **This option should not be combined with -r**"); _o.setArgs(1); _o.setOptionalArg(true); _o.setArgName("applClassOnly"); _options.addOption(_o); _o = new Option(" ", "detailedStats", false, "Display detailed stats."); _o.setOptionalArg(false); _o = new Option("h", "help", false, "Display message."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("i", "output-xml-jimple-before-res", false, "Output xml representation of the jimple BEFORE residualization."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("j", "output-xml-jimple-after-res", false, "Output xml representation of the jimple AFTER residualization. This only works with -r option."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("I", "output-jimple-before-res", false, "Output jimple BEFORE residualization."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("J", "output-jimple-after-res", false, "Output jimple AFTER residualization. This only works with -r option."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("s", "criteria-spec-file", true, "Use the slice criteria specified in this file."); _o.setArgs(1); _o.setArgName("crit-spec-file"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("sa", "Perform scoped analysis (as opposed merely performing scoped slicing)"); _options.addOption(_o); _o = new Option("S", "slice-scope-spec-file", true, "Use the scope specified in this file."); _o.setArgs(1); _o.setArgName("slice-scope-spec-file"); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("r", "residualize", true, "Residualize after slicing. This will also dump the class files for the residualized classes. Provide the " + "name of the file as an optional argument to optimize the slice (via transformation) for space. The file should" + "contain the FQN of classes (1 per line) to be retained during optimization."); _o.setOptionalArg(true); _options.addOption(_o); _o = new Option("x", "output-slice-xml", false, "Output xml representation of the slice."); _o.setOptionalArg(false); _options.addOption(_o); _o = new Option("l", true, "Generate criteria based on line number based criteria spec file. The format is " + "<class FQN>=<comma-separated list of line numbers from the class containing Java file>."); _o.setArgs(1); _o.setArgName("line-based-criteria-spec-file"); _o.setOptionalArg(false); _options.addOption(_o); CommandLine _cl = null; // parse the arguments Exception _exception = null; try { _cl = (new BasicParser()).parse(_options, args); } catch (ParseException _e) { _exception = _e; } if (_exception != null || _cl.hasOption("h")) { printUsage(_options); if (_exception != null) { LOGGER.error("Incorrect command line. Aborting.", _exception); System.exit(1); } else { System.exit(0); } } xmlizer.setConfiguration(processCommandLineForConfiguration(_cl)); setupOutputOptions(_cl, xmlizer); if (_cl.hasOption('p')) { xmlizer.addToSootClassPath(_cl.getOptionValue('p')); } if (_cl.hasOption('a')) { xmlizer.setConfigName(_cl.getOptionValue('a')); } if (_cl.hasOption('g')) { xmlizer.showGUI(); } if (_cl.hasOption('s')) { xmlizer.setSliceCriteriaSpecFile(_cl.getOptionValue('s')); } if (_cl.hasOption('r')) { xmlizer.setResidulization(true); final String _optionValue = _cl.getOptionValue('r'); if (_optionValue != null) { xmlizer.extractExclusionListForCompaction(_optionValue); } } if (_cl.hasOption('S')) { sliceScope = xmlizer.setScopeSpecFile(_cl.getOptionValue('S')); if (_cl.hasOption("sa")) { xmlizer.setScopeSpecFile(_cl.getOptionValue('S')); } else { xmlizer.setScopeSpecFile(null); } } if (_cl.hasOption('l')) { xmlizer.setLineBasedCriteriaSpecFile(_cl.getOptionValue('l')); } xmlizer.preserveThrowStatements = _cl.hasOption('e'); if (xmlizer.preserveThrowStatements) { xmlizer.parseThrowStmtTreatmentOptions(_cl.getOptionValue('e')); } if (xmlizer.generateSeparateSlicesForEachThrowStmt && xmlizer.residualize) { throw new IllegalArgumentException( "Residualization (-r) cannot be combined multiple slice generation mode (-e separateSlices)."); } xmlizer.detailedStats = _cl.hasOption("detailedStats"); xmlizer.shouldWriteSliceXML = _cl.hasOption('x'); final List<String> _result = _cl.getArgList(); if (_result.isEmpty()) { LOGGER.error( "Please specify atleast one class that contains an entry method into the system to be sliced."); System.exit(1); } xmlizer.setClassNames(_result); }
From source file:com.github.dakusui.symfonion.CLI.java
public void analyze(CommandLine cmd) throws CLIException { if (cmd.hasOption('O')) { String optionName = "O"; this.midiouts = initializeMidiPorts(cmd, optionName); }// www. ja v a 2 s .com if (cmd.hasOption('I')) { String optionName = "I"; this.midiins = initializeMidiPorts(cmd, optionName); } if (cmd.hasOption('o')) { String sinkFilename = getSingleOptionValue(cmd, "o"); if (sinkFilename == null) { String msg = composeErrMsg("Output filename is required by this option.", "o", null); throw new CLIException(msg); } this.sink = new File(sinkFilename); } if (cmd.hasOption("V") || cmd.hasOption("version")) { this.mode = Mode.VERSION; } else if (cmd.hasOption("h") || cmd.hasOption("help")) { this.mode = Mode.HELP; } else if (cmd.hasOption("l") || cmd.hasOption("list")) { this.mode = Mode.LIST; } else if (cmd.hasOption("p") || cmd.hasOption("play")) { this.mode = Mode.PLAY; String sourceFilename = getSingleOptionValue(cmd, "p"); if (sourceFilename == null) { String msg = composeErrMsg("Input filename is required by this option.", "p", null); throw new CLIException(msg); } this.source = new File(sourceFilename); } else if (cmd.hasOption("c") || cmd.hasOption("compile")) { this.mode = Mode.COMPILE; String sourceFilename = getSingleOptionValue(cmd, "c"); if (sourceFilename == null) { String msg = composeErrMsg("Input filename is required by this option.", "c", null); throw new CLIException(msg); } this.source = new File(sourceFilename); } else if (cmd.hasOption("r") || cmd.hasOption("route")) { this.mode = Mode.ROUTE; Properties props = cmd.getOptionProperties("r"); if (props.size() != 1) { String msg = composeErrMsg("Route information is not given or specified multiple times.", "r", "route"); throw new CLIException(msg); } this.route = new Route(cmd.getOptionValues('r')[0], cmd.getOptionValues('r')[1]); } else { @SuppressWarnings("unchecked") List<String> leftovers = cmd.getArgList(); if (leftovers.size() == 0) { this.mode = Mode.HELP; } else if (leftovers.size() == 1) { this.mode = Mode.PLAY; this.source = new File(leftovers.get(0)); } else { String msg = composeErrMsg( String.format("Unrecognized arguments:%s", leftovers.subList(2, leftovers.size())), "-", null); throw new CLIException(msg); } } }
From source file:com.databasepreservation.cli.CLI.java
/** * Obtains the arguments needed to create new import and export modules * * @param factoriesPair/*w w w.j a v a 2s.co m*/ * A pair of DatabaseModuleFactory objects containing the selected * import and export module factories * @param args * The command line arguments * @return A DatabaseModuleFactoriesArguments containing the arguments to * create the import and export modules * @throws ParseException * If the arguments could not be parsed or are invalid */ private DatabaseModuleFactoriesArguments getModuleArguments(DatabaseModuleFactoriesPair factoriesPair, List<String> args) throws ParseException, OperationNotSupportedException { DatabaseModuleFactory importModuleFactory = factoriesPair.getImportModuleFactory(); DatabaseModuleFactory exportModuleFactory = factoriesPair.getExportModuleFactory(); // get appropriate command line options CommandLineParser commandLineParser = new DefaultParser(); CommandLine commandLine; Options options = new Options(); HashMap<String, Parameter> mapOptionToParameter = new HashMap<String, Parameter>(); for (Parameter parameter : importModuleFactory.getImportModuleParameters().getParameters()) { Option option = parameter.toOption("i", "import"); options.addOption(option); mapOptionToParameter.put(getUniqueOptionIdentifier(option), parameter); } for (ParameterGroup parameterGroup : importModuleFactory.getImportModuleParameters().getGroups()) { OptionGroup optionGroup = parameterGroup.toOptionGroup("i", "import"); options.addOptionGroup(optionGroup); for (Parameter parameter : parameterGroup.getParameters()) { mapOptionToParameter.put(getUniqueOptionIdentifier(parameter.toOption("i", "import")), parameter); } } for (Parameter parameter : exportModuleFactory.getExportModuleParameters().getParameters()) { Option option = parameter.toOption("e", "export"); options.addOption(option); mapOptionToParameter.put(getUniqueOptionIdentifier(option), parameter); } for (ParameterGroup parameterGroup : exportModuleFactory.getExportModuleParameters().getGroups()) { OptionGroup optionGroup = parameterGroup.toOptionGroup("e", "export"); options.addOptionGroup(optionGroup); for (Parameter parameter : parameterGroup.getParameters()) { mapOptionToParameter.put(getUniqueOptionIdentifier(parameter.toOption("e", "export")), parameter); } } Option importOption = Option.builder("i").longOpt("import").hasArg().optionalArg(false).build(); Option exportOption = Option.builder("e").longOpt("export").hasArg().optionalArg(false).build(); Option pluginOption = Option.builder("p").longOpt("plugin").hasArg().optionalArg(false).build(); options.addOption(importOption); options.addOption(exportOption); options.addOption(pluginOption); // new HelpFormatter().printHelp(80, "dbptk", "\nModule Options:", options, // null, true); // parse the command line arguments with those options try { commandLine = commandLineParser.parse(options, args.toArray(new String[] {}), false); if (!commandLine.getArgList().isEmpty()) { throw new ParseException("Unrecognized option: " + commandLine.getArgList().get(0)); } } catch (MissingOptionException e) { // use long names instead of short names in the error message List<String> missingShort = e.getMissingOptions(); List<String> missingLong = new ArrayList<String>(); for (String shortOption : missingShort) { missingLong.add(options.getOption(shortOption).getLongOpt()); } LOGGER.debug("MissingOptionException (the original, unmodified exception)", e); throw new MissingOptionException(missingLong); } // create arguments to pass to factory HashMap<Parameter, String> importModuleArguments = new HashMap<Parameter, String>(); HashMap<Parameter, String> exportModuleArguments = new HashMap<Parameter, String>(); for (Option option : commandLine.getOptions()) { Parameter p = mapOptionToParameter.get(getUniqueOptionIdentifier(option)); if (p != null) { if (isImportModuleOption(option)) { if (p.hasArgument()) { importModuleArguments.put(p, option.getValue(p.valueIfNotSet())); } else { importModuleArguments.put(p, p.valueIfSet()); } } else if (isExportModuleOption(option)) { if (p.hasArgument()) { exportModuleArguments.put(p, option.getValue(p.valueIfNotSet())); } else { exportModuleArguments.put(p, p.valueIfSet()); } } else { throw new ParseException("Unexpected parse exception occurred."); } } } return new DatabaseModuleFactoriesArguments(importModuleArguments, exportModuleArguments); }
From source file:com.marklogic.shell.command.load.java
public void execute(Environment env, String[] args) { if (args != null && args.length > 0) { CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try {/* ww w . j a va 2s . c o m*/ cmd = parser.parse(options, args); } catch (ParseException e) { env.outputException(e); return; } ContentCreateOptions contentOptions = new ContentCreateOptions(); String quality = cmd.getOptionValue("q"); if (quality != null) { try { Integer q = Integer.valueOf(quality); contentOptions.setQuality(q.intValue()); } catch (NumberFormatException e) { env.outputError("Invalid document quality (must be an int): " + quality); return; } } String docType = cmd.getOptionValue("t"); if (docType != null) { if ("binary".equals(docType)) { contentOptions.setFormat(DocumentFormat.BINARY); } else if ("text".equals(docType)) { contentOptions.setFormat(DocumentFormat.TEXT); } else if ("xml".equals(docType)) { contentOptions.setFormat(DocumentFormat.XML); } else { env.outputError("Invalid document format. Must be: binary,text,xml"); return; } } String[] cols = cmd.getOptionValues("c"); if (cols != null && cols.length > 0) { contentOptions.setCollections(cols); } String[] perms = cmd.getOptionValues("x"); if (perms != null && perms.length > 0) { List contentPermissions = new ArrayList(); for (int i = 0; i < perms.length; i++) { ContentCapability ccap = null; String p = perms[i]; if (p == null) { env.outputError("Invalid permission option. Must be of the form: 'capability:role'"); return; } String[] parts = p.split(":"); if (parts == null || parts.length != 2) { env.outputError("Invalid permission option. Must be of the form: 'capability:role'"); return; } String capability = parts[0]; String role = parts[1]; if ("execute".equals(capability)) { ccap = ContentCapability.EXECUTE; } else if ("insert".equals(capability)) { ccap = ContentCapability.INSERT; } else if ("read".equals(capability)) { ccap = ContentCapability.READ; } else if ("update".equals(capability)) { ccap = ContentCapability.UPDATE; } else { env.outputError("Invalid permission '" + p + "'. Capability must be one of: execute,insert,read,update"); return; } if (role == null || role.length() == 0) { env.outputError("Invalid permission. Please provide a role"); return; } contentPermissions.add(new ContentPermission(ccap, role)); } ContentPermission[] cperms = new ContentPermission[contentPermissions.size()]; contentPermissions.toArray(cperms); contentOptions.setPermissions(cperms); } env.outputLine("Loading files..."); int total = 0; for (Iterator i = cmd.getArgList().iterator(); i.hasNext();) { String path = i.next().toString(); List files = FileScanner.findFiles(path); if (files != null && files.size() > 0) { List list = new ArrayList(); for (Iterator it = files.iterator(); it.hasNext();) { File f = (File) it.next(); String uri = cmd.getOptionValue("n"); if (uri == null || uri.length() == 0) { uri = getUri(cmd.getOptionValue("i"), f.getName()); } list.add(ContentFactory.newContent(uri, f, contentOptions)); } Content[] contentList = new Content[list.size()]; list.toArray(contentList); Session session = env.getContentSource().newSession(); try { session.insertContent(contentList); total += contentList.length; } catch (RequestException e) { env.outputException(e); } } else { env.outputLine("No file(s) found at location " + path + "."); } } if (total > 0) { env.outputLine("Done. Loaded " + total + " file(s)."); } } else { env.outputLine("You must specify a file path to load."); } }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Perform initialization before the GUI is contstructed. This method is * called by the swing application framework * // w ww. j av a 2s.c o m * @param args * - Command line arguments from the main method */ @Override protected void initialize(String[] args) { ResourceMap resourceMap = getContext().getResourceMap(Intkey.class); resourceMap.injectFields(this); // Define and parse command line arguments Options options = new Options(); options.addOption("A", false, "Startup in advanced mode."); options.addOption("I", false, "Suppress display of startup images."); Option preferencesOption = OptionBuilder.withArgName("filename").hasArg() .withDescription("Use the specified file as the preferences file.").create("P"); options.addOption(preferencesOption); boolean cmdLineParseSuccess = true; CommandLineParser parser = new GnuParser(); try { CommandLine cmdLine = parser.parse(options, args, false); if (cmdLine.hasOption("A")) { _advancedMode = true; } if (cmdLine.hasOption("I")) { _suppressStartupImages = true; } if (cmdLine.hasOption("P")) { _startupPreferencesFile = cmdLine.getOptionValue("P"); if (StringUtils.isEmpty(_startupPreferencesFile)) { cmdLineParseSuccess = false; } } if (cmdLine.getArgList().size() == 1) { _datasetInitFileToOpen = (String) cmdLine.getArgList().get(0); } if (cmdLine.getArgList().size() > 1) { cmdLineParseSuccess = false; } } catch (ParseException ex) { cmdLineParseSuccess = false; } if (!cmdLineParseSuccess) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Intkey [dataset-init-file] [options]", options); System.exit(0); } // If _startupInAdvancedMode has not already been set to true using the // "-A" command line option (see above), // Check saved application state for the mode (advanced or basic) that // was last used in the application. if (!_advancedMode) { _advancedMode = UIUtils.getPreviousApplicationMode(); } // Get location of last opened dataset from saved application state _lastOpenedDatasetDirectory = UIUtils.getSavedLastOpenedDatasetDirectory(); }
From source file:fr.ujm.tse.lt2c.satin.main.Main.java
/** * @param args//from w ww .ja v a 2 s .co m * @return a ReasoningArguements object containing all the parsed arguments */ private static ReasoningArguments getArguments(final String[] args) { /* Reasoner fields */ int threadsNB = DEFAULT_THREADS_NB; int bufferSize = DEFAULT_BUFFER_SIZE; long timeout = DEFAULT_TIMEOUT; int iteration = 1; ReasonerProfile profile = DEFAULT_PROFILE; /* Extra fields */ boolean verboseMode = DEFAULT_VERBOSE_MODE; boolean warmupMode = DEFAULT_WARMUP_MODE; boolean dumpMode = DEFAULT_DUMP_MODE; boolean batchMode = DEFAULT_BATCH_MODE; /* * Options */ final Options options = new Options(); final Option bufferSizeO = new Option("b", "buffer-size", true, "set the buffer size"); bufferSizeO.setArgName("size"); bufferSizeO.setArgs(1); bufferSizeO.setType(Number.class); options.addOption(bufferSizeO); final Option timeoutO = new Option("t", "timeout", true, "set the buffer timeout in ms (0 means timeout will be disabled)"); bufferSizeO.setArgName("time"); bufferSizeO.setArgs(1); bufferSizeO.setType(Number.class); options.addOption(timeoutO); final Option iterationO = new Option("i", "iteration", true, "how many times each file "); iterationO.setArgName("number"); iterationO.setArgs(1); iterationO.setType(Number.class); options.addOption(iterationO); final Option directoryO = new Option("d", "directory", true, "infers on all ontologies in the directory"); directoryO.setArgName("directory"); directoryO.setArgs(1); directoryO.setType(File.class); options.addOption(directoryO); options.addOption("o", "output", false, "save output into file"); options.addOption("h", "help", false, "print this message"); options.addOption("v", "verbose", false, "enable verbose mode"); options.addOption("r", "batch-reasoning", false, "enable batch reasoning"); options.addOption("w", "warm-up", false, "insert a warm-up lap before the inference"); final Option profileO = new Option("p", "profile", true, "set the fragment " + java.util.Arrays.asList(ReasonerProfile.values())); profileO.setArgName("profile"); profileO.setArgs(1); options.addOption(profileO); final Option threadsO = new Option("n", "threads", true, "set the number of threads by available core (0 means the jvm manage)"); threadsO.setArgName("number"); threadsO.setArgs(1); threadsO.setType(Number.class); options.addOption(threadsO); /* * Arguments parsing */ final CommandLineParser parser = new GnuParser(); final CommandLine cmd; try { cmd = parser.parse(options, args); } catch (final ParseException e) { LOGGER.error("", e); return null; } /* help */ if (cmd.hasOption("help")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("main", options); return null; } /* buffer */ if (cmd.hasOption("buffer-size")) { final String arg = cmd.getOptionValue("buffer-size"); try { bufferSize = Integer.parseInt(arg); } catch (final NumberFormatException e) { LOGGER.error("Buffer size must be a number. Default value used", e); } } /* timeout */ if (cmd.hasOption("timeout")) { final String arg = cmd.getOptionValue("timeout"); try { timeout = Integer.parseInt(arg); } catch (final NumberFormatException e) { LOGGER.error("Timeout must be a number. Default value used", e); } } /* verbose */ if (cmd.hasOption("verbose")) { verboseMode = true; if (LOGGER.isInfoEnabled()) { LOGGER.info("Verbose mode enabled"); } } /* warm-up */ if (cmd.hasOption("warm-up")) { warmupMode = true; if (LOGGER.isInfoEnabled()) { LOGGER.info("Warm-up mode enabled"); } } /* dump */ if (cmd.hasOption("output")) { dumpMode = true; if (LOGGER.isInfoEnabled()) { LOGGER.info("Dump mode enabled"); } } /* dump */ if (cmd.hasOption("batch-reasoning")) { batchMode = true; if (LOGGER.isInfoEnabled()) { LOGGER.info("Batch mode enabled"); } } /* directory */ String dir = null; if (cmd.hasOption("directory")) { for (final Object o : cmd.getOptionValues("directory")) { String arg = o.toString(); if (arg.startsWith("~" + File.separator)) { arg = System.getProperty("user.home") + arg.substring(1); } final File directory = new File(arg); if (!directory.exists()) { LOGGER.warn("**Cant not find " + directory); } else if (!directory.isDirectory()) { LOGGER.warn("**" + directory + " is not a directory"); } else { dir = directory.getAbsolutePath(); } } } /* profile */ if (cmd.hasOption("profile")) { final String string = cmd.getOptionValue("profile"); switch (string) { case "RhoDF": profile = ReasonerProfile.RHODF; break; case "BRhoDF": profile = ReasonerProfile.BRHODF; break; case "RDFS": profile = ReasonerProfile.RDFS; break; case "BRDFS": profile = ReasonerProfile.BRDFS; break; default: LOGGER.warn("Profile unknown, default profile used: " + DEFAULT_PROFILE); profile = DEFAULT_PROFILE; break; } } /* threads */ if (cmd.hasOption("threads")) { final String arg = cmd.getOptionValue("threads"); try { threadsNB = Integer.parseInt(arg); } catch (final NumberFormatException e) { LOGGER.error("Threads number must be a number. Default value used", e); } } /* iteration */ if (cmd.hasOption("iteration")) { final String arg = cmd.getOptionValue("iteration"); try { iteration = Integer.parseInt(arg); } catch (final NumberFormatException e) { LOGGER.error("Iteration must be a number. Default value used", e); } } final List<File> files = new ArrayList<>(); if (dir != null) { final File directory = new File(dir); final File[] listOfFiles = directory.listFiles(); for (final File file : listOfFiles) { // Maybe other extensions ? if (file.isFile() && file.getName().endsWith(".nt")) { files.add(file); } } } for (final Object o : cmd.getArgList()) { String arg = o.toString(); if (arg.startsWith("~" + File.separator)) { arg = System.getProperty("user.home") + arg.substring(1); } final File file = new File(arg); if (!file.exists()) { LOGGER.warn("**Cant not find " + file); } else if (file.isDirectory()) { LOGGER.warn("**" + file + " is a directory"); } else { files.add(file); } } Collections.sort(files, new Comparator<File>() { @Override public int compare(final File f1, final File f2) { if (f1.length() > f2.length()) { return 1; } if (f2.length() > f1.length()) { return -1; } return 0; } }); if (LOGGER.isInfoEnabled()) { LOGGER.info("********* OPTIONS *********"); LOGGER.info("Buffer size: " + bufferSize); LOGGER.info("Profile: " + profile); if (threadsNB > 0) { LOGGER.info("Threads: " + threadsNB); } else { LOGGER.info("Threads: Automatic"); } LOGGER.info("Iterations: " + iteration); LOGGER.info("Timeout: " + timeout); LOGGER.info("***************************"); } return new ReasoningArguments(threadsNB, bufferSize, timeout, iteration, profile, verboseMode, warmupMode, dumpMode, batchMode, files); }
From source file:net.zdechov.sharpmz.jmzemu.JMzEmu.java
/** * Main method launching the application. * * @param args arguments/*from ww w. ja va2 s . co m*/ */ public static void main(String[] args) { try { preferences = Preferences.userNodeForPackage(JMzEmu.class); } catch (SecurityException ex) { preferences = null; } try { bundle = LanguageUtils.getResourceBundleByClass(JMzEmu.class); // Parameters processing Options opt = new Options(); opt.addOption("h", "help", false, bundle.getString("cl_option_help")); opt.addOption("v", false, bundle.getString("cl_option_verbose")); opt.addOption("dev", false, bundle.getString("cl_option_dev")); BasicParser parser = new BasicParser(); CommandLine cl = parser.parse(opt, args); if (cl.hasOption('h')) { HelpFormatter f = new HelpFormatter(); f.printHelp(bundle.getString("cl_syntax"), opt); } else { verboseMode = cl.hasOption("v"); devMode = cl.hasOption("dev"); Logger logger = Logger.getLogger(""); try { logger.setLevel(Level.ALL); logger.addHandler(new XBHead.XBLogHandler(verboseMode)); } catch (java.security.AccessControlException ex) { // Ignore it in java webstart } XBBaseApplication app = new XBBaseApplication(); app.setAppPreferences(new PreferencesWrapper(preferences)); app.setAppBundle(bundle, LanguageUtils.getResourceBaseNameBundleByClass(JMzEmu.class)); XBApplicationModuleRepository moduleRepository = app.getModuleRepository(); moduleRepository.addClassPathModules(); moduleRepository.addModulesFromManifest(JMzEmu.class); moduleRepository.loadModulesFromPath(new File("plugins").toURI()); moduleRepository.initModules(); app.init(); GuiFrameModuleApi frameModule = moduleRepository.getModuleByInterface(GuiFrameModuleApi.class); GuiEditorModuleApi editorModule = moduleRepository.getModuleByInterface(GuiEditorModuleApi.class); GuiMenuModuleApi menuModule = moduleRepository.getModuleByInterface(GuiMenuModuleApi.class); GuiAboutModuleApi aboutModule = moduleRepository.getModuleByInterface(GuiAboutModuleApi.class); GuiFileModuleApi fileModule = moduleRepository.getModuleByInterface(GuiFileModuleApi.class); GuiOptionsModuleApi optionsModule = moduleRepository .getModuleByInterface(GuiOptionsModuleApi.class); GuiUpdateModuleApi updateModule = moduleRepository.getModuleByInterface(GuiUpdateModuleApi.class); frameModule.createMainMenu(); // try { // updateModule.setUpdateUrl(new URL(bundle.getString("update_url"))); // updateModule.setUpdateDownloadUrl(new URL(bundle.getString("update_download_url"))); // } catch (MalformedURLException ex) { // Logger.getLogger(JMzEmu.class.getName()).log(Level.SEVERE, null, ex); // } updateModule.registerDefaultMenuItem(); aboutModule.registerDefaultMenuItem(); AboutDialogSidePanel sidePanel = new AboutDialogSidePanel(); aboutModule.setAboutDialogSideComponent(sidePanel); frameModule.registerExitAction(); frameModule.registerBarsVisibilityActions(); // Register clipboard editing actions fileModule.registerMenuFileHandlingActions(); fileModule.registerToolBarFileHandlingActions(); fileModule.registerLastOpenedMenuActions(); fileModule.registerCloseListener(); // undoModule.registerMainMenu(); // undoModule.registerMainToolBar(); // undoModule.registerUndoManagerInMainMenu(); // Register clipboard editing actions menuModule.getClipboardActions(); // menuModule.registerMenuClipboardActions(); // menuModule.registerToolBarClipboardActions(); optionsModule.registerMenuAction(); // HexPanel hexPanel = (HexPanel) deltaHexModule.getEditorProvider(); // editorModule.registerEditor("hex", hexPanel); // editorModule.registerUndoHandler(); // undoModule.setUndoHandler(hexPanel.getHexUndoHandler()); // deltaHexModule.registerStatusBar(); // deltaHexModule.registerOptionsPanels(); // deltaHexModule.getTextStatusPanel(); updateModule.registerOptionsPanels(); // deltaHexModule.loadFromPreferences(preferences); ApplicationFrameHandler frameHandler = frameModule.getFrameHandler(); GraphicsModule graphicsModule = new GraphicsModule(); frameHandler.setMainPanel(graphicsModule.getGraphicsComponent()); frameHandler.setDefaultSize(new Dimension(600, 400)); frameHandler.show(); updateModule.checkOnStart(frameHandler.getFrame()); List fileArgs = cl.getArgList(); if (fileArgs.size() > 0) { fileModule.loadFromFile((String) fileArgs.get(0)); } } } catch (ParseException | RuntimeException ex) { Logger.getLogger(JMzEmu.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.agiso.tempel.starter.Bootstrap.java
@Override public void run(String... args) throws Exception { // Konfiguracja opcji i parsowanie argumentw: Options options = configureTempelOptions(); // Parsowanie parametrw wejciowych: CommandLine cmd = parseTempelCommandArgs(options, args); // Wywietlanie pomocy dla wywoania z parametrem 'help': if (cmd.hasOption('h')) { printTempelHelp(options);/*from www . j a va 2 s . c o m*/ System.exit(0); } // Okrelanie katalogu roboczego i katalogu repozytorium: String workDir = determineWorkDir(cmd); // Pobieranie nazwy szablonu do wykonania: String templateName; if (cmd.getArgList().size() != 1) { System.err.println("Incorrect params. Use \"tpl --help\" for help."); System.exit(-1); } templateName = String.valueOf(cmd.getArgList().get(0)); // Budowanie mapy parametrw dodatkowych (okrelanych przez -Dkey=value): Map<String, String> params = new HashMap<String, String>(); Properties properties = cmd.getOptionProperties("D"); Enumeration<?> propertiesEnumeration = properties.propertyNames(); while (propertiesEnumeration.hasMoreElements()) { String key = (String) propertiesEnumeration.nextElement(); params.put(key, properties.getProperty(key)); } // Uruchamianie generatora dla okrelonego szablonu: starterLogger.info(Logs.LOG_01, ansiString(GREEN, templateName)); try { if (PARAM_READER != null) { tempel.setParamReader(PARAM_READER); } tempel.startTemplate(templateName, params, workDir); starterLogger.info(Logs.LOG_02, ansiString(GREEN, templateName)); } catch (Exception e) { starterLogger.error(e, Logs.LOG_06, ansiString(RED, e.getMessage())); System.exit(-4); } }
From source file:org.apache.accumulo.core.trace.TraceDump.java
private static int dumpTrace(CommandLine commandLine) throws Exception { final PrintStream out = System.out; InstanceUserPassword info = getInstance(commandLine); Connector conn = info.instance.getConnector(info.username, info.password); int count = 0; for (Object arg : commandLine.getArgList()) { Scanner scanner = conn.createScanner(TRACE_TABLE, conn.securityOperations().getUserAuthorizations(info.username)); Range range = new Range(new Text(arg.toString())); scanner.setRange(range);//w w w.j a va2s .c o m count = printTrace(scanner, new Printer() { @Override public void print(String line) { out.println(line); } }); } return count > 0 ? 0 : 1; }
From source file:org.apache.accumulo.core.util.shell.commands.AddSplitsCommand.java
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final boolean decode = cl.hasOption(base64Opt.getOpt()); final TreeSet<Text> splits = new TreeSet<Text>(); if (cl.hasOption(optSplitsFile.getOpt())) { final String f = cl.getOptionValue(optSplitsFile.getOpt()); String line;// w w w. j a va2s. c om java.util.Scanner file = new java.util.Scanner(new File(f), Constants.UTF8.name()); while (file.hasNextLine()) { line = file.nextLine(); if (!line.isEmpty()) { splits.add( decode ? new Text(Base64.decodeBase64(line.getBytes(Constants.UTF8))) : new Text(line)); } } } else { if (cl.getArgList().isEmpty()) { throw new MissingArgumentException("No split points specified"); } for (String s : cl.getArgs()) { splits.add(new Text(s.getBytes(Shell.CHARSET))); } } if (!shellState.getConnector().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.getConnector().tableOperations().addSplits(tableName, splits); return 0; }