Examples of ArgParser


Examples of argparser.ArgParser

   * @param args
   *            The command line arguments.
   */
  public Main(String[] args)
    {
        final ArgParser parser = new ArgParser("java -jar venn.jar <arguments>");
       
        BooleanHolder   versionOpt = new BooleanHolder();
       
        StringHolder    configFile = new StringHolder(),
                        outConfigFile = new StringHolder(),
                        listFile = new StringHolder(),
                        gceFile = new StringHolder(),
                        seFile = new StringHolder(),
                        htGceFile = new StringHolder(),
                        filterFile = new StringHolder(),
                        optStateFile = new StringHolder(),
                        outFilterFile = new StringHolder(),
                        svgFile = new StringHolder(),
                        simFile = new StringHolder(),
                        profFile = new StringHolder();
    
        // create the parser and specify the allowed options ...
        parser.addOption("--version,-v %v #show VennMaster version", versionOpt);
        parser.addOption("--cfg %s #input configuration file", configFile);
        parser.addOption("--ocfg %s #output configuration file", outConfigFile);
        parser.addOption("--list %s #list input file", listFile);
        parser.addOption("--gce %s #GoMiner gene-category export file", gceFile);
        parser.addOption("--se %s #GoMiner summary export file", seFile);
        parser.addOption("--htgce %s #High-Throughput GoMiner gce file", htGceFile);
        parser.addOption("--filter %s #gene filter for GoMinor import.", filterFile);
        parser.addOption("--ofilter %s #output filter file", outFilterFile);
        parser.addOption("--optstate %s #output of the optimizer state",optStateFile);
        parser.addOption("--svg %s #generates an SVG file of the Venn diagram", svgFile);
        parser.addOption("--sim %s #output of the simulation profile",simFile);
        parser.addOption("--prof %s #output of the final error profile",profFile);
       
        parser.matchAllArgs(args);
       
        System.out.println( "VennMaster version "+
                            Constants.VERSION_MAJOR+"."+Constants.VERSION_MINOR+"."+Constants.VERSION_SUB+"  ("+Constants.VERSION_DATE+")");
        if( versionOpt.value )
        {
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

    }

    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("MGRSPoint");
        ap.add("mgrs", "Print Latitude and Longitude for MGRS value", 1);
        ap.add("latlon",
                "Print MGRS for Latitude and Longitude values",
                2,
                true);
        ap.add("sets", "Print the MGRS 100k table");
        ap.add("altsets", "Print the MGRS 100k table for the Bessel ellipsoid");
        ap.add("rtc",
                "Run test case, with filename and input data type [MGRS | UTM | LatLon]",
                2);

        if (!ap.parse(argv)) {
            ap.printUsage();
            System.exit(0);
        }

        String arg[];
        arg = ap.getArgValues("sets");
        if (arg != null) {
            new MGRSPoint().print100kSets();
        }

        arg = ap.getArgValues("altsets");
        if (arg != null) {
            MGRSPoint mgrsp = new MGRSPoint();
            mgrsp.setOriginColumnLetters(BESSEL_SET_ORIGIN_COLUMN_LETTERS);
            mgrsp.setOriginRowLetters(BESSEL_SET_ORIGIN_ROW_LETTERS);
            mgrsp.print100kSets();
        }

        arg = ap.getArgValues("mgrs");
        if (arg != null) {
            try {
                MGRSPoint mgrsp = new MGRSPoint(arg[0]);
                Debug.output(arg[0] + " is " + mgrsp.toLatLonPoint());
            } catch (NumberFormatException nfe) {
                Debug.error(nfe.getMessage());
            }
        }

        arg = ap.getArgValues("latlon");
        if (arg != null) {
            try {

                float lat = Float.parseFloat(arg[0]);
                float lon = Float.parseFloat(arg[1]);

                LatLonPoint llp = new LatLonPoint(lat, lon);
                MGRSPoint mgrsp = LLtoMGRS(llp);
                UTMPoint utmp = LLtoUTM(llp);

                if (utmp.zone_letter == 'Z') {
                    Debug.output(llp + "to UTM: latitude limit exceeded.");
                } else {
                    Debug.output(llp + " is " + utmp);
                }

                Debug.output(llp + " is " + mgrsp);

            } catch (NumberFormatException nfe) {
                Debug.error("The numbers provided:  " + argv[0] + ", "
                        + argv[1] + " aren't valid");
            }
        }

        arg = ap.getArgValues("rtc");
        if (arg != null) {
            runTests(arg[0], arg[1]);
        }

    }
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     *        statement.
     */
    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("Wanderer");

        if (argv.length == 0) {
            ap.bail("", true);
        }

        String[] dirs = argv;

        Wanderer wanderer = new Wanderer(new TestWandererCallback());
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     *        usage statement.
     */
    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("Purge");

        if (argv.length == 0) {
            ap.bail("Wanders through directory tree pruning '~' files.\nUsage: java com.bbn.openmap.util.wanderer.Purge <dir>",
                    false);
        }

        Purge purge = new Purge(new String[] { ".#" }, new String[] { "~" });

View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     *        usage statement.
     */
    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("SVG2GIF");
        ap.add("dimension",
                "Dimension of output image, add height and width arguments separated by a space",
                2);

        if (argv.length == 0) {
            ap.bail("Usage: java com.bbn.openmap.util.wanderer.SVG <dir> (-help for options)",
                    false);
        }

        ap.parse(argv);

        Dimension dim = null;
        String[] arg = ap.getArgValues("dimension");
        if (arg != null) {

            String heightString = arg[0];
            String widthString = arg[1];

            Debug.output("Creating images with height (" + heightString
                    + ") width (" + widthString + ")");
            try {
                int width = Integer.parseInt(widthString);
                int height = Integer.parseInt(heightString);
                dim = new Dimension(width, height);
            } catch (NumberFormatException nfe) {
                String message = "Problem reading dimensions: " + nfe.getMessage();
                ap.bail(message, false);
            }
        }

        String[] dirs = ap.getRest();

        SVG2GIF svg2gif = new SVG2GIF();
        if (dim != null) {
            svg2gif.setDimension(dim);
        }
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     *        usage statement.
     */
    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("SLOC");

        if (argv.length == 0) {
            ap.bail("Counts ';' and '}' to sum up Source Lines Of Code\nUsage: java com.bbn.openmap.util.wanderer.SLOC <dir>",
                    false);
        }

        ap.parse(argv);

        String[] dirs = argv;

        SLOC sloc = new SLOC();
        Wanderer wanderer = new Wanderer(sloc);
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

    /**
     */
    public static void main(String[] argv) {
        Debug.init();

        ArgParser ap = new ArgParser("OneWaySync");
        ap.add("source",
                "The source directory to copy files and directories from.",
                1);
        ap.add("target",
                "The target directory to receive the updated files and directories.",
                1);
        ap.add("verbose",
                "Announce all changes, failures will still be reported.");
        ap.add("fakeit",
                "Just print what would happen, don't really do anything.");
        ap.add("report",
                "Print out what didn't get copied, and what files exist only on the target side.");

        if (argv.length < 4) {
            ap.bail("", true);
        }

        ap.parse(argv);

        boolean verbose = false;
        String[] verb = ap.getArgValues("verbose");
        if (verb != null) {
            verbose = true;
        }

        boolean fakeit = false;
        verb = ap.getArgValues("fakeit");
        if (verb != null) {
            verbose = true;
            fakeit = true;
        }

        boolean report = false;
        verb = ap.getArgValues("report");
        if (verb != null) {
            report = true;
        }

        String[] sourceDir;
        sourceDir = ap.getArgValues("source");
        if (sourceDir != null || sourceDir.length < 1) {
            if (verbose)
                Debug.output("Source directory is " + sourceDir[0]);
        } else {
            ap.bail("OneWaySync needs path to source directory", false);
        }

        String[] targetDir;
        targetDir = ap.getArgValues("target");
        if (targetDir != null || targetDir.length < 1) {
            if (verbose)
                Debug.output("Target directory is " + targetDir[0]);
        } else {
            ap.bail("OneWaySync needs path to source directory", false);
        }

        OneWaySync cc = new OneWaySync(sourceDir[0], targetDir[0]);
        cc.setVerbose(verbose);
        cc.setFakeit(fakeit);
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     */
    public static void main(String[] argv) {
        Debug.init();
        boolean toUpper = true;

        ArgParser ap = new ArgParser("ChangeCase");
        ap.add("upper",
                "Change file and directory names to UPPER CASE (default). <path> <path> ...",
                ArgParser.TO_END);
        ap.add("lower",
                "Change file and directory names to lower case. <path> <path> ...",
                ArgParser.TO_END);
        ap.add("verbose",
                "Announce all changes, failures will still be reported.");

        if (argv.length == 0) {
            ap.bail("", true);
        }

        ap.parse(argv);

        String[] dirs;
        dirs = ap.getArgValues("lower");
        if (dirs != null) {
            Debug.output("Converting to lower case names...");
            toUpper = false;
        } else {
            dirs = ap.getArgValues("upper");
            // No arguments given, going to default.
            if (dirs == null) {
                dirs = argv;
            }
            Debug.output("Converting to UPPER CASE names...");
        }

        boolean verbose = false;
        String[] verboseTest = ap.getArgValues("verbose");
        if (verboseTest != null) {
            verbose = true;
        }

        ChangeCase cc = new ChangeCase(toUpper);
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

    }

    public static void main(String[] args) {
        Debug.init();

        ArgParser ap = new ArgParser("EsriGraphicList");
        ap.add("fixcl", "Check and fix content length of Shape file", 1);
        ap.add("print", "Display text structure of shapes in Shape file", 1);

        if (!ap.parse(args)) {
            ap.printUsage();
            System.exit(0);
        }

        String[] fixit = ap.getArgValues("fixcl");
        if (fixit != null) {
            String shape = fixit[0];
            if (shape.endsWith(".shp")) {
                shape = shape.substring(0, shape.length() - 4);

                try {
                    URL shx = PropUtils.getResourceOrFileOrURL(shape + ".shx");
                    InputStream is = shx.openStream();
                    ShxInputStream pis = new ShxInputStream(is);
                    int[][] index = pis.getIndex();
                    is.close();
                   
                    RandomAccessFile raf = new RandomAccessFile(shape + ".shp", "rw");
                    raf.seek(24);
                    int contentLength = raf.readInt();
                   
                    int indexedContentLength = index[0][index[0].length - 1] + index[1][index[1].length - 1];
                   
                    if (contentLength != indexedContentLength) {
                        System.out.println(shape + " content length - shp: " + contentLength + ", shx: " + indexedContentLength);
                        raf.seek(24);
                        raf.writeInt(indexedContentLength);
                    }
                    raf.close();
                   
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
            } else {
                System.out.println("Shape " + shape
                        + " doesn't look like a shape file");
            }
        }

        String[] printit = ap.getArgValues("print");
        if (printit != null) {
            try {

                URL eglURL = PropUtils.getResourceOrFileOrURL(printit[0]);
                EsriGraphicList egl = EsriGraphicList.getEsriGraphicList(eglURL,
View Full Code Here

Examples of com.bbn.openmap.util.ArgParser

     *
     * @param args
     */
    public static void main(String[] args) {
        Debug.init();
        ArgParser ap = new ArgParser("RpfUtil");
        ap.add("copy",
                "Copy RPF data from one RPF directory to another. (-copy from to)",
                2);
        ap.add("delete",
                "Delete RPF data from a RPF directory. (-delete from)",
                1);
        ap.add("maketoc",
                "Create an A.TOC file in a RPF directory. (-maketoc from).",
                1);
        ap.add("zip",
                "Create a zip file from a RPF directory. (-zip zipFileName from)",
                2);
        ap.add("query",
                "Print the paths of files that fit the criteria, but do nothing",
                1);
        ap.add("scale",
                "The scale to use for criteria in matching chart types, followed by a letter describing the relationship of matching frame scales to give scale ('g'reater than, 'l'ess than, 'n'ot equal to, 'e'qual to). (optional)",
                2);
        ap.add("boundary",
                "Coordinates of bounding box (upper lat, left lon, lower lat, right lon) (optional)",
                4,
                true);
        ap.add("inside",
                "Flag to manage RPF frames inside bounding box. (default, optional)");
        ap.add("outside",
                "Flag to manage RPF frames outside bounding box. (optional)");
        ap.add("verbose", "Print out progress");
        ap.add("extraverbose", "Print out ALL progress");

        if (!ap.parse(args)) {
            ap.printUsage();
            System.exit(0);
        }

        float ulat = 90f;
        float llat = -90f;
        float llon = -180f;
        float rlon = 180f;

        String arg[];
        arg = ap.getArgValues("boundary");
        if (arg != null) {
            boolean boundaryCoordinateProblem = true;
            try {
                ulat = Float.parseFloat(arg[0]);
                llon = Float.parseFloat(arg[1]);
                llat = Float.parseFloat(arg[2]);
                rlon = Float.parseFloat(arg[3]);

                boundaryCoordinateProblem = ulat > 90 || llon < -180
                        || llat < -90 || rlon > 180 || ulat <= llat
                        || llon >= rlon;

            } catch (NumberFormatException nfe) {
                Debug.error("Parsing error for boundary coordinates");
            }

            if (boundaryCoordinateProblem) {
                Debug.error("Boundary coordinates are screwy...");
                ap.printUsage();
                System.exit(0);
            }
        }

        RpfUtil rpfUtil = new RpfUtil(ulat, llon, llat, rlon);

        rpfUtil.verbose = (ap.getArgValues("verbose") != null);

        arg = ap.getArgValues("outside");
        if (arg != null) {
            rpfUtil.setBoundaryLimits(RpfUtil.OUTSIDE);
        }

        arg = ap.getArgValues("inside");
        if (arg != null) {
            rpfUtil.setBoundaryLimits(RpfUtil.INSIDE);
        }

        arg = ap.getArgValues("scale");
        if (arg != null) {
            try {
                rpfUtil.setScale(Float.parseFloat(arg[0]));
                rpfUtil.setScaleDelim(arg[1].charAt(0));
            } catch (NumberFormatException nfe) {
                Debug.error("Scale value is screwy...");
                ap.printUsage();
                System.exit(0);
            }
        }

        arg = ap.getArgValues("query");
        if (arg != null) {
            rpfUtil.query(arg[0]);
            System.exit(0);
        }

        arg = ap.getArgValues("copy");
        if (arg != null) {
            rpfUtil.setRpfDir(arg[0]);
            if (!rpfUtil.copy(arg[1])) {
                Debug.output("Problem copying frames");
            }
        }

        arg = ap.getArgValues("delete");
        if (arg != null && !rpfUtil.delete(arg[0])) {
            Debug.output("Problem deleting files.");
        }

        arg = ap.getArgValues("maketoc");
        if (arg != null && !rpfUtil.maketoc(arg[0])) {
            Debug.output("Problem creating A.TOC file for frames.");
        }

        arg = ap.getArgValues("zip");
        if (arg != null && !rpfUtil.zip(arg[0], arg[1])) {
            Debug.output("Problem creating zip file: " + arg[0]);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.