Example usage for org.apache.commons.cli Options addOptionGroup

List of usage examples for org.apache.commons.cli Options addOptionGroup

Introduction

In this page you can find the example usage for org.apache.commons.cli Options addOptionGroup.

Prototype

public Options addOptionGroup(OptionGroup group) 

Source Link

Document

Add the specified option group.

Usage

From source file:com.hurence.logisland.plugin.PluginManager.java

public static void main(String... args) throws Exception {
    System.out.println(BannerLoader.loadBanner());

    String logislandHome = new File(
            new File(PluginManager.class.getProtectionDomain().getCodeSource().getLocation().getPath())
                    .getParent()).getParent();
    System.out.println("Using Logisland home: " + logislandHome);
    Options options = new Options();
    OptionGroup mainGroup = new OptionGroup()
            .addOption(OptionBuilder.withDescription(
                    "Install a component. It can be either a logisland plugin or a kafka connect module.")
                    .withArgName("artifact").hasArgs(1).withLongOpt("install").create("i"))
            .addOption(OptionBuilder.withDescription(
                    "Removes a component. It can be either a logisland plugin or a kafka connect module.")
                    .withArgName("artifact").hasArgs(1).withLongOpt("remove").create("r"))
            .addOption(OptionBuilder.withDescription("List installed components.").withLongOpt("list")
                    .create("l"));

    mainGroup.setRequired(true);/*from www .jav  a 2s . c  o  m*/
    options.addOptionGroup(mainGroup);
    options.addOption(OptionBuilder.withDescription("Print this help.").withLongOpt("help").create("h"));

    try {
        CommandLine commandLine = new PosixParser().parse(options, args);
        System.out.println(commandLine.getArgList());
        if (commandLine.hasOption("l")) {
            listPlugins();
        } else if (commandLine.hasOption("i")) {
            installPlugin(commandLine.getOptionValue("i"), logislandHome);

        } else if (commandLine.hasOption("r")) {
            removePlugin(commandLine.getOptionValue("r"));
        } else {
            printUsage(options);
        }

    } catch (ParseException e) {
        if (!options.hasOption("h")) {
            System.err.println(e.getMessage());
            System.out.println();
        }
        printUsage(options);

    }
}

From source file:asl.seedscan.SeedScan.java

public static void main(String args[]) {
    // Default locations of config and schema files
    File configFile = new File("config.xml");
    File schemaFile = new File("schemas/SeedScanConfig.xsd");
    boolean parseConfig = true;

    ArrayList<File> schemaFiles = new ArrayList<File>();
    schemaFiles.add(schemaFile);//from   w  ww. j  av  a  2  s  . c om

    // ==== Command Line Parsing ====
    Options options = new Options();
    Option opConfigFile = new Option("c", "config-file", true,
            "The config file to use for seedscan. XML format according to SeedScanConfig.xsd.");
    Option opSchemaFile = new Option("s", "schema-file", true,
            "The xsd schema file which should be used to verify the config file format. ");

    OptionGroup ogConfig = new OptionGroup();
    ogConfig.addOption(opConfigFile);

    OptionGroup ogSchema = new OptionGroup();
    ogConfig.addOption(opSchemaFile);

    options.addOptionGroup(ogConfig);
    options.addOptionGroup(ogSchema);

    PosixParser optParser = new PosixParser();
    CommandLine cmdLine = null;
    try {
        cmdLine = optParser.parse(options, args, true);
    } catch (org.apache.commons.cli.ParseException e) {
        logger.error("Error while parsing command-line arguments.");
        System.exit(1);
    }

    Option opt;
    Iterator<?> iter = cmdLine.iterator();
    while (iter.hasNext()) {
        opt = (Option) iter.next();
        if (opt.getOpt().equals("c")) {
            configFile = new File(opt.getValue());
        } else if (opt.getOpt().equals("s")) {
            schemaFile = new File(opt.getValue());
        }
    }

    // ==== Configuration Read and Parse Actions ====
    ConfigParser parser = new ConfigParser(schemaFiles);
    ConfigT config = parser.parseConfig(configFile);

    // Print out configuration file contents
    Formatter formatter = new Formatter(new StringBuilder(), Locale.US);

    // ===== CONFIG: LOCK FILE =====
    File lockFile = new File(config.getLockfile());
    logger.info("SeedScan lock file is '" + lockFile + "'");
    LockFile lock = new LockFile(lockFile);
    if (!lock.acquire()) {
        logger.error("Could not acquire lock.");
        System.exit(1);
    }

    // ===== CONFIG: LOGGING =====
    // MTH: This is now done in log4j.properties file

    // ===== CONFIG: DATABASE =====
    MetricDatabase readDB = new MetricDatabase(config.getDatabase());
    MetricDatabase writeDB = new MetricDatabase(config.getDatabase());
    MetricReader reader = new MetricReader(readDB);
    MetricInjector injector = new MetricInjector(writeDB);

    // ===== CONFIG: SCANS =====
    Hashtable<String, Scan> scans = new Hashtable<String, Scan>();
    if (config.getScans().getScan() == null) {
        logger.error("No scans in configuration.");
        System.exit(1);
    } else {
        for (ScanT scanCfg : config.getScans().getScan()) {
            String name = scanCfg.getName();
            if (scans.containsKey(name)) {
                logger.error("Duplicate scan name '" + name + "' encountered.");
                System.exit(1);
            }

            // This should really be handled by jaxb by setting it up in schemas/SeedScanConfig.xsd
            if (scanCfg.getStartDay() == null && scanCfg.getStartDate() == null) {
                logger.error(
                        "== SeedScan Error: Must set EITHER cfg:start_day -OR- cfg:start_date in config.xml to start Scan!");
                System.exit(1);
            }

            // Configure this Scan
            Scan scan = new Scan(scanCfg.getName());
            scan.setPathPattern(scanCfg.getPath());
            scan.setDatalessDir(scanCfg.getDatalessDir());
            scan.setEventsDir(scanCfg.getEventsDir());
            scan.setPlotsDir(scanCfg.getPlotsDir());
            scan.setDaysToScan(scanCfg.getDaysToScan().intValue());
            if (scanCfg.getStartDay() != null) {
                scan.setStartDay(scanCfg.getStartDay().intValue());
            }
            if (scanCfg.getStartDate() != null) {
                scan.setStartDate(scanCfg.getStartDate().intValue());
            }

            if (scanCfg.getNetworkSubset() != null) {
                logger.debug("Filter on Network Subset=[{}]", scanCfg.getNetworkSubset());
                Filter filter = new Filter(false);
                for (String network : scanCfg.getNetworkSubset().split(",")) {
                    logger.debug("Network =[{}]", network);
                    filter.addFilter(network);
                }
                scan.setNetworks(filter);
            }
            if (scanCfg.getStationSubset() != null) {
                logger.debug("Filter on Station Subset=[{}]", scanCfg.getStationSubset());
                Filter filter = new Filter(false);
                for (String station : scanCfg.getStationSubset().split(",")) {
                    logger.debug("Station =[{}]", station);
                    filter.addFilter(station);
                }
                scan.setStations(filter);
            }
            if (scanCfg.getLocationSubset() != null) {
                logger.debug("Filter on Location Subset=[{}]", scanCfg.getLocationSubset());
                Filter filter = new Filter(false);
                for (String location : scanCfg.getLocationSubset().split(",")) {
                    logger.debug("Location =[{}]", location);
                    filter.addFilter(location);
                }
                scan.setLocations(filter);
            }
            if (scanCfg.getChannelSubset() != null) {
                logger.debug("Filter on Channel Subset=[{}]", scanCfg.getChannelSubset());
                Filter filter = new Filter(false);
                for (String channel : scanCfg.getChannelSubset().split(",")) {
                    logger.debug("Channel =[{}]", channel);
                    filter.addFilter(channel);
                }
                scan.setChannels(filter);
            }

            for (MetricT met : scanCfg.getMetrics().getMetric()) {
                try {
                    Class<?> metricClass = Class.forName(met.getClassName());
                    MetricWrapper wrapper = new MetricWrapper(metricClass);
                    for (ArgumentT arg : met.getArgument()) {
                        wrapper.add(arg.getName(), arg.getValue());
                    }
                    scan.addMetric(wrapper);
                } catch (ClassNotFoundException ex) {
                    logger.error("No such metric class '" + met.getClassName() + "'");
                    System.exit(1);
                } catch (InstantiationException ex) {
                    logger.error("Could not dynamically instantiate class '" + met.getClassName() + "'");
                    System.exit(1);
                } catch (IllegalAccessException ex) {
                    logger.error("Illegal access while loading class '" + met.getClassName() + "'");
                    System.exit(1);
                } catch (NoSuchFieldException ex) {
                    logger.error("Invalid dynamic argument to Metric subclass '" + met.getClassName() + "'");
                    System.exit(1);
                }

            }
            scans.put(name, scan);
        }
    }

    // ==== Establish Database Connection ====
    // TODO: State Tracking in the Database
    // - Record scan started in database.
    // - Track our progress as we go so a new process can pick up where
    //   we left off if our process dies.
    // - Mark when each date-station-channel-operation is complete
    //LogDatabaseHandler logDB = new LogDatabaseHandler(configuration.get

    // For each day ((yesterday - scanDepth) to yesterday)
    // scan for these channel files, only process them if
    // they have not yet been scanned, or if changes have
    // occurred to the file since its last scan. Do this for
    // each scan type. Do not re-scan data for each type,
    // launch processes for each scan and use the same data set
    // for each. If we can pipe the data as it is read, do so.
    // If we need to push all of it at once, do these in sequence
    // in order to preserve overall system memory resources.

    Scan scan = null;

    // ==== Perform Scans ====

    scan = scans.get("daily");

    //MTH: This part could/should be moved up higher except that we need to know datalessDir, which,
    //     at this point, is configured on a per scan basis ... so we need to know what scan we're doing
    MetaServer metaServer = null;
    if (config.getMetaserver() != null) {
        if (config.getMetaserver().getUseRemote().equals("yes")
                || config.getMetaserver().getUseRemote().equals("true")) {
            String remoteServer = config.getMetaserver().getRemoteUri();
            try {
                metaServer = new MetaServer(new URI(remoteServer));
            } catch (Exception e) {
                logger.error("caught URI exception:" + e.getMessage());
            }
        } else {
            metaServer = new MetaServer(scan.getDatalessDir());
        }
    } else { // Use local MetaServer
        metaServer = new MetaServer(scan.getDatalessDir());
    }

    List<Station> stations = null;

    if (config.getStationList() == null) { // get StationList from MetaServer
        logger.info("Get StationList from MetaServer");
        stations = metaServer.getStationList();
    } else { // read StationList from config.xml
        logger.info("Read StationList from config.xml");
        List<String> stationList = config.getStationList().getStation();
        if (stationList.size() > 0) {
            stations = new ArrayList<Station>();
            for (String station : stationList) {
                String[] words = station.split("_");
                if (words.length != 2) {
                    logger.warn(String.format("stationList: station=[%s] is NOT a valid station --> Skip",
                            station));
                } else {
                    stations.add(new Station(words[0], words[1]));
                    logger.info("config.xml: Read station:" + station);
                }
            }
        } else {
            logger.error("Error: No valid stations read from config.xml");
        }
    }

    if (stations == null) {
        logger.error("Found NO stations to scan --> EXITTING SeedScan");
        System.exit(1);
    }

    Thread readerThread = new Thread(reader);
    readerThread.start();
    logger.info("Reader thread started.");

    Thread injectorThread = new Thread(injector);
    injectorThread.start();
    logger.info("Injector thread started.");

    // Loop over scans and hand each one to a ScanManager
    logger.info("Hand scan to ScanManager");
    for (String key : scans.keySet()) {
        scan = scans.get(key);
        logger.info(String.format("Scan=[%s] startDay=%d startDate=%d daysToScan=%d\n", key, scan.getStartDay(),
                scan.getStartDate(), scan.getDaysToScan()));
        ScanManager scanManager = new ScanManager(reader, injector, stations, scan, metaServer);
    }

    logger.info("ScanManager is [ FINISHED ] --> stop the injector and reader threads");

    try {
        injector.halt();
        logger.info("All stations processed. Waiting for injector thread to finish...");
        synchronized (injectorThread) {
            //injectorThread.wait();
            injectorThread.interrupt();
        }
        logger.info("Injector thread halted.");
    } catch (InterruptedException ex) {
        logger.warn("The injector thread was interrupted while attempting to complete requests.");
    }

    try {
        reader.halt();
        logger.info("All stations processed. Waiting for reader thread to finish...");
        synchronized (readerThread) {
            //readerThread.wait();
            readerThread.interrupt();
        }
        logger.info("Reader thread halted.");
    } catch (InterruptedException ex) {
        logger.warn("The reader thread was interrupted while attempting to complete requests.");
    }

    try {
        lock.release();
    } catch (IOException e) {
        ;
    } finally {
        logger.info("Release seedscan lock and quit metaServer");
        lock = null;
        metaServer.quit();
    }
}

From source file:edu.harvard.hul.ois.fits.Fits.java

public static void main(String[] args) throws FitsException, IOException, ParseException, XMLStreamException {
    Fits fits = new Fits();

    Options options = new Options();
    options.addOption("i", true, "input file or directory");
    options.addOption("r", false, "process directories recursively when -i is a directory ");
    options.addOption("o", true, "output file");
    options.addOption("h", false, "print this message");
    options.addOption("v", false, "print version information");
    OptionGroup outputOptions = new OptionGroup();
    Option stdxml = new Option("x", false, "convert FITS output to a standard metadata schema");
    Option combinedStd = new Option("xc", false,
            "output using a standard metadata schema and include FITS xml");
    outputOptions.addOption(stdxml);//from   ww w .  j  av  a2  s.c  om
    outputOptions.addOption(combinedStd);
    options.addOptionGroup(outputOptions);

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("h")) {
        fits.printHelp(options);
        System.exit(0);
    }
    if (cmd.hasOption("v")) {
        System.out.println(Fits.VERSION);
        System.exit(0);
    }
    if (cmd.hasOption("r")) {
        traverseDirs = true;
    } else {
        traverseDirs = false;
    }

    if (cmd.hasOption("i")) {
        String input = cmd.getOptionValue("i");
        File inputFile = new File(input);

        if (inputFile.isDirectory()) {
            String outputDir = cmd.getOptionValue("o");
            if (outputDir == null || !(new File(outputDir).isDirectory())) {
                throw new FitsException(
                        "When FITS is run in directory processing mode the output location must be a diretory");
            }
            fits.doDirectory(inputFile, new File(outputDir), cmd.hasOption("x"), cmd.hasOption("xc"));
        } else {
            FitsOutput result = fits.doSingleFile(inputFile);
            fits.outputResults(result, cmd.getOptionValue("o"), cmd.hasOption("x"), cmd.hasOption("xc"), false);
        }
    } else {
        System.err.println("Invalid CLI options");
        fits.printHelp(options);
        System.exit(-1);
    }

    System.exit(0);
}

From source file:fdtutilscli.Main.java

/**
 * //w w  w  .  j a  va 2 s  .c  om
 * @param args the command line arguments
 */
public static void main(String[] args) {

    CommandLineParser parser = new PosixParser();
    CommandLine line = null;
    Options options = new Options();
    OptionGroup optCommand = new OptionGroup();
    OptionGroup optOutput = new OptionGroup();
    HelpFormatter formatter = new HelpFormatter();
    TRACE trace = TRACE.DEFAULT;

    optCommand.addOption(OptionBuilder.withArgName("ndf odf nif key seperator").hasArgs(5)
            .withValueSeparator(' ').withDescription("Description").create("delta"));
    optCommand.addOption(OptionBuilder.withArgName("dupsfile key seperator").hasArgs(3)
            .withDescription("Description").create("duplicates"));
    optCommand.addOption(OptionBuilder.withLongOpt("help").withDescription("print this message.").create("h"));
    optCommand.addOption(
            OptionBuilder.withLongOpt("version").withDescription("print version information.").create("V"));
    optOutput.addOption(new Option("verbose", "be extra verbose"));
    optOutput.addOption(new Option("quiet", "be extra quiet"));
    optOutput.addOption(new Option("silent", "same as --quiet"));
    options.addOptionGroup(optCommand);
    options.addOptionGroup(optOutput);

    try {
        line = parser.parse(options, args);

        if (line.hasOption("verbose")) {
            trace = TRACE.VERBOSE;
        } else if (line.hasOption("quiet") || line.hasOption("silent")) {
            trace = TRACE.QUIET;
        }

        if (line.hasOption("h")) {
            formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, null, true);
            return;
        } else if (line.hasOption("V")) {
            System.out.println(APP_NAME + " version " + VERSION);
            System.out.println("fDTDeltaBuilder version " + DTDeltaBuilder.version());
            System.out.println("DTDuplicateKeyFinder version " + DTDuplicateKeyFinder.version());
            return;
        } else if (line.hasOption("delta")) {
            String ndf = line.getOptionValues("delta")[0];
            String odf = line.getOptionValues("delta")[1];
            String nif = line.getOptionValues("delta")[2];
            Integer key = (line.getOptionValues("delta").length <= 3) ? DEFAULT_KEY
                    : new Integer(line.getOptionValues("delta")[3]);
            String seperator = (line.getOptionValues("delta").length <= 4) ? DEFAULT_SEPERATOR
                    : line.getOptionValues("delta")[4];

            doDelta(ndf, odf, nif, key.intValue(), seperator, trace);

            return;
        } else if (line.hasOption("duplicates")) {
            String dupsFile = line.getOptionValues("duplicates")[0];
            Integer key = (line.getOptionValues("duplicates").length <= 1) ? DEFAULT_KEY
                    : new Integer(line.getOptionValues("duplicates")[1]);
            String seperator = (line.getOptionValues("duplicates").length <= 2) ? DEFAULT_SEPERATOR
                    : line.getOptionValues("duplicates")[2];
            doDuplicates(dupsFile, key.intValue(), seperator, trace);
            return;
        } else if (args.length == 0) {
            formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, null, true);
        } else {
            throw new UnrecognizedOptionException(E_MSG_UNREC_OPT);
        }

    } catch (UnrecognizedOptionException e) {
        formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, HELP_FOOTER + e.getMessage(), true);
    } catch (ParseException e) {
        formatter.printHelp(HELP_SYNTAX, HELP_HEADER, options, HELP_FOOTER + e.getMessage(), true);
    }
}

From source file:edu.cornell.med.icb.R.RUtils.java

public static void main(final String[] args) throws ParseException, ConfigurationException {
    final Options options = new Options();

    final Option helpOption = new Option("h", "help", false, "Print this message");
    options.addOption(helpOption);//  www .  j  av a 2s. c  o m

    final Option startupOption = new Option(Mode.startup.name(), Mode.startup.name(), false,
            "Start Rserve process");
    final Option shutdownOption = new Option(Mode.shutdown.name(), Mode.shutdown.name(), false,
            "Shutdown Rserve process");
    final Option validateOption = new Option(Mode.validate.name(), Mode.validate.name(), false,
            "Validate that Rserve processes are running");

    final OptionGroup optionGroup = new OptionGroup();
    optionGroup.addOption(startupOption);
    optionGroup.addOption(shutdownOption);
    optionGroup.addOption(validateOption);
    optionGroup.setRequired(true);
    options.addOptionGroup(optionGroup);

    final Option portOption = new Option("port", "port", true,
            "Use specified port to communicate with the Rserve process");
    portOption.setArgName("port");
    portOption.setType(int.class);
    options.addOption(portOption);

    final Option hostOption = new Option("host", "host", true,
            "Communicate with the Rserve process on the given host");
    hostOption.setArgName("hostname");
    hostOption.setType(String.class);
    options.addOption(hostOption);

    final Option userOption = new Option("u", "username", true, "Username to send to the Rserve process");
    userOption.setArgName("username");
    userOption.setType(String.class);
    options.addOption(userOption);

    final Option passwordOption = new Option("p", "password", true, "Password to send to the Rserve process");
    passwordOption.setArgName("password");
    passwordOption.setType(String.class);
    options.addOption(passwordOption);

    final Option configurationOption = new Option("c", "configuration", true,
            "Configuration file or url to read from");
    configurationOption.setArgName("configuration");
    configurationOption.setType(String.class);
    options.addOption(configurationOption);

    final Parser parser = new BasicParser();
    final CommandLine commandLine;
    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException e) {
        usage(options);
        throw e;
    }

    int exitStatus = 0;
    if (commandLine.hasOption("h")) {
        usage(options);
    } else {
        Mode mode = null;
        for (final Mode potentialMode : Mode.values()) {
            if (commandLine.hasOption(potentialMode.name())) {
                mode = potentialMode;
                break;
            }
        }

        final ExecutorService threadPool = Executors.newCachedThreadPool();

        if (commandLine.hasOption("configuration")) {
            final String configurationFile = commandLine.getOptionValue("configuration");
            LOG.info("Reading configuration from " + configurationFile);
            XMLConfiguration configuration;
            try {
                final URL configurationURL = new URL(configurationFile);
                configuration = new XMLConfiguration(configurationURL);
            } catch (MalformedURLException e) {
                // resource is not a URL: attempt to get the resource from a file
                LOG.debug("Configuration is not a valid url");
                configuration = new XMLConfiguration(configurationFile);
            }

            configuration.setValidating(true);
            final int numberOfRServers = configuration.getMaxIndex("RConfiguration.RServer") + 1;
            boolean failed = false;
            for (int i = 0; i < numberOfRServers; i++) {
                final String server = "RConfiguration.RServer(" + i + ")";
                final String host = configuration.getString(server + "[@host]");
                final int port = configuration.getInt(server + "[@port]",
                        RConfigurationUtils.DEFAULT_RSERVE_PORT);
                final String username = configuration.getString(server + "[@username]");
                final String password = configuration.getString(server + "[@password]");
                final String command = configuration.getString(server + "[@command]", DEFAULT_RSERVE_COMMAND);

                if (executeMode(mode, threadPool, host, port, username, password, command) != 0) {
                    failed = true; // we have other hosts to check so keep a failed state
                }
            }
            if (failed) {
                exitStatus = 3;
            }
        } else {
            final String host = commandLine.getOptionValue("host", "localhost");
            final int port = Integer.valueOf(commandLine.getOptionValue("port", "6311"));
            final String username = commandLine.getOptionValue("username");
            final String password = commandLine.getOptionValue("password");

            exitStatus = executeMode(mode, threadPool, host, port, username, password, null);
        }
        threadPool.shutdown();
    }

    System.exit(exitStatus);
}

From source file:LNISmokeTest.java

/**
 * Execute command line. See Usage string for options and arguments.
 * //  w  w  w.  j  a v a 2 s.  c om
 * @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:Executable.LinkImputeR.java

/**
 * Main function//from   w ww  .  j  a v  a  2  s  . c o m
 * @param args Command line arguments
 * @throws Exception If an uncaught error occurs
 */
public static void main(String[] args) throws Exception {
    try {
        Options options = new Options();

        OptionGroup all = new OptionGroup();
        all.addOption(Option.builder("c").build());
        all.addOption(Option.builder("s").build());
        all.addOption(Option.builder("v").build());
        all.addOption(Option.builder("h").build());
        options.addOptionGroup(all);

        CommandLineParser parser = new DefaultParser();
        CommandLine commands = parser.parse(options, args);

        String[] fileNames = commands.getArgs();

        XMLConfiguration c;
        boolean done = false;

        if (commands.hasOption("c")) {
            if (fileNames.length == 2) {
                c = convert(new File(fileNames[0]));
                writeXML(c, new File(fileNames[1]));
            } else {
                System.out.println("An input and output file must be provided");
                System.out.println();
                help();
            }
            done = true;
        }

        if (commands.hasOption("s")) {
            if (fileNames.length == 1) {
                c = convert(new File(fileNames[0]));
                accuracy(c);
            } else {
                System.out.println("An input file must be provided");
                System.out.println();
                help();
            }
            done = true;
        }

        if (commands.hasOption("v")) {
            System.out.println("LinkImputeR version 1.1.3");
            done = true;
        }

        if (commands.hasOption("h")) {
            help();
            done = true;
        }

        if (!done) {
            if (fileNames.length == 3) {
                File xml = new File(fileNames[0]);

                FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(
                        XMLConfiguration.class).configure(new Parameters().xml().setFile(xml));

                XMLConfiguration config = builder.getConfiguration();

                switch (config.getString("mode")) {
                case "accuracy":
                    accuracy(config);
                    break;
                case "impute":
                    if (args.length == 3) {
                        impute(config, args[1], new File(args[2]));
                    } else {
                        impute(config, null, null);
                    }
                    break;
                }
            } else {
                System.out.println("An input file, case name and output file must be provided (in that order)");
                System.out.println();
                help();
            }
        }
    } catch (UnrecognizedOptionException ex) {
        System.err.println("Unrecognised command line option (" + ex.getOption() + ")");
        System.err.println();
        help();
    } catch (AlreadySelectedException ex) {
        System.err.println("Only one option can be selected at a time");
        System.err.println();
        help();
    } catch (VCFException ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("There's a problem with the VCF file");
        System.err.println(ex.getMessage());
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    } catch (INIException ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("There's a problem with the ini file");
        System.err.println(ex.getMessage());
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    } catch (OutputException ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("There's a problem writing an output file");
        System.err.println(ex.getMessage());
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    } catch (AlgorithmException ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("There's a problem with the algorithms");
        System.err.println(ex.getMessage());
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    } catch (ProgrammerException ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("Well this is embarrassing.  This shouldn't have happened.  "
                + "Please contact the maintainer if you can not solve the error"
                + "from the technical details.");
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    } catch (Exception ex) {
        System.err.println("=====");
        System.err.println("ERROR");
        System.err.println("=====");
        System.err.println("Well this is embarrassing.  This was not expected to have happened.  "
                + "Please contact the maintainer if you can not solve the error"
                + "from the technical details.");
        System.err.println();
        System.err.println("Note: The maintainer would be interested in knowing "
                + "about any XML related messages so he can write nicer error "
                + "messages for these problems.");
        System.err.println();
        System.err.println("Technical details follow:");
        throw ex;
    }
}

From source file:name.wagners.fssp.Main.java

/**
 * @param args//from   w  w w  .jav a 2  s.co m
 *            command-line arguments
 */
public static void main(final String[] args) {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();

    options.addOption(OptionBuilder.hasArg().withArgName("gn").withLongOpt("generations")
            .withDescription("Number of generations [default: 50]").withType(Integer.valueOf(0)).create("g"));

    options.addOption(OptionBuilder.hasArg().withArgName("mp").withLongOpt("mutation")
            .withDescription("Mutation propability [default: 0.5]").withType(Double.valueOf(0)).create("m"));

    options.addOption(OptionBuilder.hasArg().withArgName("ps").withLongOpt("populationsize")
            .withDescription("Size of population [default: 20]").withType(Integer.valueOf(0)).create("p"));

    options.addOption(OptionBuilder.hasArg().withArgName("rp").withLongOpt("recombination")
            .withDescription("Recombination propability [default: 0.8]").withType(Double.valueOf(0))
            .create("r"));

    options.addOption(OptionBuilder.hasArg().withArgName("sp").withLongOpt("selectionpressure")
            .withDescription("Selection pressure [default: 4]").withType(Integer.valueOf(0)).create("s"));

    options.addOption(OptionBuilder.withLongOpt("help").withDescription("print this message").create("h"));

    options.addOption(OptionBuilder.hasArg().withArgName("filename").isRequired().withLongOpt("file")
            .withDescription("Problem file [default: \"\"]").withType(String.valueOf("")).create("f"));

    options.addOptionGroup(new OptionGroup()
            .addOption(OptionBuilder.withLongOpt("verbose").withDescription("be extra verbose").create("v"))
            .addOption(OptionBuilder.withLongOpt("quiet").withDescription("be extra quiet").create("q")));

    options.addOption(OptionBuilder.withLongOpt("version")
            .withDescription("print the version information and exit").create("V"));

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        // validate that block-size has been set
        if (line.hasOption("h")) {
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("fssp", options);
        }

    } catch (MissingOptionException exp) {
        log.info("An option was missing:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (MissingArgumentException exp) {
        log.info("An argument was missing:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (AlreadySelectedException exp) {
        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (ParseException exp) {
        log.info("Unexpected exception:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);

        System.exit(1);
    }

    // Ausgabe der eingestellten Optionen

    log.info("Configuration");
    // log.info(" Datafile: {}", fname);
}

From source file:de.burlov.amazon.s3.dirsync.CLI.java

/**
 * @param args/*from   w  w w.j a v  a  2s.  c o m*/
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    Logger.getLogger("").setLevel(Level.OFF);
    Logger deLogger = Logger.getLogger("de");
    deLogger.setLevel(Level.INFO);
    Handler handler = new ConsoleHandler();
    handler.setFormatter(new VerySimpleFormatter());
    deLogger.addHandler(handler);
    deLogger.setUseParentHandlers(false);
    //      if (true)
    //      {
    //         LogFactory.getLog(CLI.class).error("test msg", new Exception("test extception"));
    //         return;
    //      }
    Options opts = new Options();
    OptionGroup gr = new OptionGroup();

    /*
     * Befehlsgruppe initialisieren
     */
    gr = new OptionGroup();
    gr.setRequired(true);
    gr.addOption(OptionBuilder.withArgName("up|down").hasArg()
            .withDescription("Upload/Download changed or new files").create(CMD_UPDATE));
    gr.addOption(OptionBuilder.withArgName("up|down").hasArg()
            .withDescription("Upload/Download directory snapshot").create(CMD_SNAPSHOT));
    gr.addOption(OptionBuilder.withDescription("Delete remote folder").create(CMD_DELETE_DIR));
    gr.addOption(OptionBuilder.withDescription("Delete a bucket").create(CMD_DELETE_BUCKET));
    gr.addOption(OptionBuilder.create(CMD_HELP));
    gr.addOption(OptionBuilder.create(CMD_VERSION));
    gr.addOption(OptionBuilder.withDescription("Prints summary for stored data").create(CMD_SUMMARY));
    gr.addOption(OptionBuilder.withDescription("Clean up orphaned objekts").create(CMD_CLEANUP));
    gr.addOption(OptionBuilder.withDescription("Changes encryption password").withArgName("new password")
            .hasArg().create(CMD_CHANGE_PASSWORD));
    gr.addOption(OptionBuilder.withDescription("Lists all buckets").create(CMD_LIST_BUCKETS));
    gr.addOption(OptionBuilder.withDescription("Lists raw objects in a bucket").create(CMD_LIST_BUCKET));
    gr.addOption(OptionBuilder.withDescription("Lists files in remote folder").create(CMD_LIST_DIR));
    opts.addOptionGroup(gr);
    /*
     * Parametergruppe initialisieren
     */
    opts.addOption(OptionBuilder.withArgName("key").isRequired(false).hasArg().withDescription("S3 access key")
            .create(OPT_S3S_KEY));
    opts.addOption(OptionBuilder.withArgName("secret").isRequired(false).hasArg()
            .withDescription("Secret key for S3 account").create(OPT_S3S_SECRET));
    opts.addOption(OptionBuilder.withArgName("bucket").isRequired(false).hasArg().withDescription(
            "Optional bucket name for storage. If not specified then an unique bucket name will be generated")
            .create(OPT_BUCKET));
    // opts.addOption(OptionBuilder.withArgName("US|EU").hasArg().
    // withDescription(
    // "Where the new bucket should be created. Default US").create(
    // OPT_LOCATION));
    opts.addOption(OptionBuilder.withArgName("path").isRequired(false).hasArg()
            .withDescription("Local directory path").create(OPT_LOCAL_DIR));
    opts.addOption(OptionBuilder.withArgName("name").isRequired(false).hasArg()
            .withDescription("Remote directory name").create(OPT_REMOTE_DIR));
    opts.addOption(OptionBuilder.withArgName("password").isRequired(false).hasArg()
            .withDescription("Encryption password").create(OPT_ENC_PASSWORD));
    opts.addOption(OptionBuilder.withArgName("patterns").hasArgs()
            .withDescription("Comma separated exclude file patterns like '*.tmp,*/dir/*.tmp'")
            .create(OPT_EXCLUDE_PATTERNS));
    opts.addOption(OptionBuilder.withArgName("patterns").hasArgs().withDescription(
            "Comma separated include patterns like '*.java'. If not specified, then all files in specified local directory will be included")
            .create(OPT_INCLUDE_PATTERNS));

    if (args.length == 0) {
        printUsage(opts);
        return;
    }

    CommandLine cmd = null;
    try {
        cmd = new GnuParser().parse(opts, args);
        if (cmd.hasOption(CMD_HELP)) {
            printUsage(opts);
            return;
        }
        if (cmd.hasOption(CMD_VERSION)) {
            System.out.println("s3dirsync version " + Version.CURRENT_VERSION);
            return;
        }
        String awsKey = cmd.getOptionValue(OPT_S3S_KEY);
        String awsSecret = cmd.getOptionValue(OPT_S3S_SECRET);
        String bucket = cmd.getOptionValue(OPT_BUCKET);
        String bucketLocation = cmd.getOptionValue(OPT_LOCATION);
        String localDir = cmd.getOptionValue(OPT_LOCAL_DIR);
        String remoteDir = cmd.getOptionValue(OPT_REMOTE_DIR);
        String password = cmd.getOptionValue(OPT_ENC_PASSWORD);
        String exclude = cmd.getOptionValue(OPT_EXCLUDE_PATTERNS);
        String include = cmd.getOptionValue(OPT_INCLUDE_PATTERNS);

        if (StringUtils.isBlank(awsKey) || StringUtils.isBlank(awsSecret)) {
            System.out.println("S3 account data required");
            return;
        }

        if (StringUtils.isBlank(bucket)) {
            bucket = awsKey + ".dirsync";
        }

        if (cmd.hasOption(CMD_DELETE_BUCKET)) {
            if (StringUtils.isBlank(bucket)) {
                System.out.println("Bucket name required");
                return;
            }
            int deleted = S3Utils.deleteBucket(awsKey, awsSecret, bucket);
            System.out.println("Deleted objects: " + deleted);
            return;
        }
        if (cmd.hasOption(CMD_LIST_BUCKETS)) {
            for (String str : S3Utils.listBuckets(awsKey, awsSecret)) {
                System.out.println(str);
            }
            return;
        }
        if (cmd.hasOption(CMD_LIST_BUCKET)) {
            if (StringUtils.isBlank(bucket)) {
                System.out.println("Bucket name required");
                return;
            }
            for (String str : S3Utils.listObjects(awsKey, awsSecret, bucket)) {
                System.out.println(str);
            }
            return;
        }
        if (StringUtils.isBlank(password)) {
            System.out.println("Encryption password required");
            return;
        }
        char[] psw = password.toCharArray();
        DirSync ds = new DirSync(awsKey, awsSecret, bucket, bucketLocation, psw);
        ds.setExcludePatterns(parseSubargumenths(exclude));
        ds.setIncludePatterns(parseSubargumenths(include));
        if (cmd.hasOption(CMD_SUMMARY)) {
            ds.printStorageSummary();
            return;
        }
        if (StringUtils.isBlank(remoteDir)) {
            System.out.println("Remote directory name required");
            return;
        }
        if (cmd.hasOption(CMD_DELETE_DIR)) {
            ds.deleteFolder(remoteDir);
            return;
        }
        if (cmd.hasOption(CMD_LIST_DIR)) {
            Folder folder = ds.getFolder(remoteDir);
            if (folder == null) {
                System.out.println("No such folder found: " + remoteDir);
                return;
            }
            for (Map.Entry<String, FileInfo> entry : folder.getIndexData().entrySet()) {
                System.out.println(entry.getKey() + " ("
                        + FileUtils.byteCountToDisplaySize(entry.getValue().getLength()) + ")");
            }
            return;
        }
        if (cmd.hasOption(CMD_CLEANUP)) {
            ds.cleanUp();
            return;
        }
        if (cmd.hasOption(CMD_CHANGE_PASSWORD)) {
            String newPassword = cmd.getOptionValue(CMD_CHANGE_PASSWORD);
            if (StringUtils.isBlank(newPassword)) {
                System.out.println("new password required");
                return;
            }
            char[] chars = newPassword.toCharArray();
            ds.changePassword(chars);
            newPassword = null;
            Arrays.fill(chars, ' ');
            return;
        }
        if (StringUtils.isBlank(localDir)) {
            System.out.println(OPT_LOCAL_DIR + " argument required");
            return;
        }
        String direction = "";
        boolean up = false;
        boolean snapshot = false;
        if (StringUtils.isNotBlank(cmd.getOptionValue(CMD_UPDATE))) {
            direction = cmd.getOptionValue(CMD_UPDATE);
        } else if (StringUtils.isNotBlank(cmd.getOptionValue(CMD_SNAPSHOT))) {
            direction = cmd.getOptionValue(CMD_SNAPSHOT);
            snapshot = true;
        }
        if (StringUtils.isBlank(direction)) {
            System.out.println("Operation direction required");
            return;
        }
        up = StringUtils.equalsIgnoreCase(OPT_UP, direction);
        File baseDir = new File(localDir);
        if (!baseDir.exists() && !baseDir.mkdirs()) {
            System.out.println("Invalid local directory: " + baseDir.getAbsolutePath());
            return;
        }
        ds.syncFolder(baseDir, remoteDir, up, snapshot);

    } catch (DirSyncException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        printUsage(opts);

    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

From source file:bogdanrechi.xmlo.Xmlo.java

/**
 * Main method.//from  w  w w  . j  ava 2 s.  c  om
 *
 * @param args
 *          Program arguments.
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    long timeStart = System.currentTimeMillis();

    _log = Logger.getLogger(Xmlo.class);

    Options argOptions = new Options();

    OptionGroup operationTypes = new OptionGroup();

    operationTypes.addOption(
            OptionBuilder.withDescription("XPath query").hasArg().withArgName("file").create("xpath"));
    operationTypes.addOption(
            OptionBuilder.withDescription("XSLT transformation").hasArg().withArgName("file").create("xslt"));
    operationTypes.addOption(
            OptionBuilder.withDescription("XQuery (with $sourceFilePath, see XmlOperations for details)")
                    .hasArg().withArgName("file").create("xquery"));
    operationTypes
            .addOption(OptionBuilder.withDescription("XSD verify").hasArgs().withArgName("file").create("xsd"));
    operationTypes
            .addOption(OptionBuilder.withDescription("DTD verify").hasArgs().withArgName("file").create("dtd"));

    argOptions.addOptionGroup(operationTypes);

    argOptions.addOption(OptionBuilder.withDescription("on screen information while performing")
            .withLongOpt("verbose").create("v"));

    argOptions.addOption(OptionBuilder.withDescription("output non-void or invalid-type results only")
            .withLongOpt("results-only").create("o"));

    argOptions.addOption(OptionBuilder.withDescription("replicate input structure on the destination side")
            .withLongOpt("keep-structure").create("k"));

    argOptions.addOption(OptionBuilder.withDescription("recursive browsing of the target structure")
            .withLongOpt("resursive").create("r"));

    argOptions.addOption(OptionBuilder.withDescription("XPath and XQuery results not numbered")
            .withLongOpt("not-numbered").create("nn"));

    argOptions.addOption(OptionBuilder.withDescription("destination files extension").hasArg()
            .withArgName("ext").withLongOpt("extension").create("x"));

    argOptions.addOption(OptionBuilder.withDescription("target files mask").hasArg().withArgName("files mask")
            .withLongOpt("target").create("t"));

    OptionGroup destinationGroup = new OptionGroup();

    destinationGroup.addOption(OptionBuilder.withDescription("destination file").hasArg().withArgName("file")
            .withLongOpt("destination-file").create("df"));
    destinationGroup.addOption(OptionBuilder.withDescription("destination folder").hasArg()
            .withArgName("folder").withLongOpt("destination-directory").create("dd"));
    destinationGroup.addOption(OptionBuilder.withDescription("destination terminal (and verbose)")
            .withLongOpt("destination-terminal").create("dt"));

    argOptions.addOptionGroup(destinationGroup);

    argOptions.addOption(OptionBuilder.withDescription("file containing namespaces aliases").hasArg()
            .withArgName("file").withLongOpt("namespaces").create("n"));

    argOptions.addOption(OptionBuilder.withDescription("usage information").withLongOpt("help").create("h"));

    argOptions.addOption(OptionBuilder.withDescription("show examples").withLongOpt("examples").create("e"));

    argOptions.addOption(OptionBuilder.withDescription("keep blank nodes while printing")
            .withLongOpt("keep-blanks").create("b"));

    argOptions.addOption(
            OptionBuilder.withDescription("show duration for each file when the verbose option is activated")
                    .withLongOpt("show-duration").create("d"));

    CommandLineParser parser = new BasicParser();
    try {
        CommandLine cmd = parser.parse(argOptions, args);

        if (cmd.hasOption('h') || cmd.hasOption('e') || cmd.getOptions().length == 0) {
            Format.println("\n" + General.getAboutInformation("resources/xmlo/metadata.properties"));

            if (cmd.hasOption('h') || cmd.getOptions().length == 0) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("xmlo", "where:", argOptions, null, true);
                Format.println();
            }

            if (cmd.hasOption("e")) {
                String examples = Files.readTextFileFromResources("resources/xmlo/examples.txt", _errorMessage);
                if (examples != null)
                    Format.println(examples);
                else {
                    Format.println("Internal error! Please see the log file for detalis.");
                    _log.error(_errorMessage.get());

                    System.exit(1);
                }
            }

            System.exit(0);
            return;
        }

        Format.println();

        // options

        if (cmd.hasOption('r'))
            _recursive = true;

        if (cmd.hasOption('k'))
            _keepStructure = true;

        if (cmd.hasOption('o'))
            _resultsOnly = true;

        if (cmd.hasOption('v'))
            _verbose = true;

        if (cmd.hasOption('b'))
            _keepBlanks = true;

        if (cmd.hasOption('d'))
            _showDuration = true;

        if (cmd.hasOption('x'))
            _extension = "." + cmd.getOptionValue('x');

        if (cmd.hasOption("nn"))
            _notNumbered = true;

        if (cmd.hasOption("df")) {
            _destination = cmd.getOptionValue("df");

            if (Files.isFolder(_destination))
                printErrorAndExit("The destination is a folder!");

            _destinationIsFile = true;
        }

        if (cmd.hasOption("dd")) {
            _destination = cmd.getOptionValue("dd");

            if (!Files.exists(_destination))
                printErrorAndExit("The destination folder does not exist!");

            if (!Files.isFolder(_destination))
                printErrorAndExit("The destination is not a folder!");
        }

        if (cmd.hasOption("dt"))
            _destinationIsTerminal = _verbose = true;

        if (cmd.hasOption('t'))
            _target = cmd.getOptionValue('t');

        if (cmd.hasOption('n')) {
            _namespaces = cmd.getOptionValue('n');
            extractNamespacesAliases();
        }

        // operations

        if (cmd.hasOption("xpath")) {
            if (_target == null)
                _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XPATH;

            doXPath(cmd.getOptionValue("xpath"));
        }

        if (cmd.hasOption("xslt")) {
            if (_target == null)
                _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XSLT;

            doXslt(cmd.getOptionValue("xslt"));
        }

        if (cmd.hasOption("xquery")) {
            if (_target == null)
                _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XQUERY;

            doXQuery(cmd.getOptionValue("xquery"));
        }

        if (cmd.hasOption("xsd")) {
            if (_target == null)
                _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XSD;

            doXsd(cmd.getOptionValues("xsd"));
        }

        if (cmd.hasOption("dtd")) {
            if (_target == null)
                _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_DTD;

            doDtd(cmd.getOptionValues("dtd"));
        }
    } catch (ParseException e) {
        printErrorAndExit(e.getMessage());
    }

    Format.println("Finished%s.", _showDuration ? " in " + TimeMeasure.printDuration(timeStart) : "");

    if (Platform.SYSTEM_IS_LINUX)
        Format.println();

    System.exit(0);
}