Examples of ArgParser


Examples of com.persistit.util.ArgParser

                final Command command = COMMANDS.get(commandName);
                if (command != null) {
                    list.remove(0);
                    try {
                        final String[] args = list.toArray(new String[list.size()]);
                        final ArgParser ap = new ArgParser(commandName, args, command.argTemplate).strict();
                        if (!ap.isUsageOnly()) {
                            final String result = command.execute(this, ap);
                            if (result != null) {
                                _writer.println(result);
                            }
                            _lastStatus += " - done";
View Full Code Here

Examples of com.persistit.util.ArgParser

        }

    }

    public static void main(final String[] args) throws Exception {
        final ArgParser ap = new ArgParser("VolumeHeader", args, ARGS_TEMPLATE).strict();
        if (ap.isUsageOnly()) {
            return;
        }
        final Task task = new VolumeInfoTask(ap.getStringValue("path"));
        task.setMessageWriter(new PrintWriter(System.out));
        task.runTask();
    }
View Full Code Here

Examples of com.persistit.util.ArgParser

    public static void main(final String[] args) throws Exception {
        final String[] template = {
                "path||pathname of journal, e.g., /xxx/yyy/zzz_journal "
                        + "for files such as /xxx/yyy/zzz_journal.0000000000000047",
                "_flags|t|emit transaction details" };
        final ArgParser argParser = new ArgParser("RecoveryManager", args, template).strict();
        final Persistit persistit = new Persistit();
        persistit.initializeJournal();
        final RecoveryManager rman = new RecoveryManager(persistit);
        rman.init(argParser.getStringValue("path"));
        rman.analyze();
    }
View Full Code Here

Examples of dijjer.util.ArgParser

  String arg2Val = null;
  boolean arg3Called = false;
  boolean unmatchedCalled = false;

    public void testParse() throws Exception {
      ArgParser parser = new ArgParser("NAME", false);
      parser.addArgument("arg1", "desc1", new ArgParser.ArgumentAction() {
        public void performAction(String arg) throws Exception {
          arg1Val = arg;
        }
      });
      parser.addArgument("arg2", "desc2", new ArgParser.ArgumentAction() {
        public void performAction(String arg) throws Exception {
          arg2Val = arg;
        }
      });
      parser.addArgument("arg3", "desc3", new ArgParser.ArgumentAction() {
        public void performAction(String arg) throws Exception {
          arg3Called = true;
        }
      });
      parser.addUnmatchedKeyArgument("xxx","yyy", new ArgParser.ArgumentAction() {
        public void performAction(String arg) throws Exception {
          unmatchedCalled = true;
        }
      });
      parser.parse(new String[] {"arg1=foo", "arg2=bar"});
      assertEquals("foo", arg1Val);
      assertEquals("bar", arg2Val);
      assertFalse(arg3Called);
      parser.parse(new String[]{"arg3=foo", "arg1=bar"});
      assertEquals("bar", arg1Val);
      assertEquals("bar", arg2Val);
      assertTrue(arg3Called);
      parser.parse(new String[]{"xxx"});
      assertTrue(unmatchedCalled);
    }
View Full Code Here

Examples of org.python.core.ArgParser

        return new PyTuple(new PyObject[] { new PyList(getArray()) });
    }

    private static PyObject struct_time_new(PyNewWrapper wrapper, boolean init, PyType subtype, PyObject[] args,
            String[] keywords) {
        ArgParser ap = new ArgParser("struct_time", args, keywords, new String[] { "tuple" }, 1);
        PyObject obj = ap.getPyObject(0);
        if (obj instanceof PyTuple) {
            if (obj.__len__() != 9) {
                throw Py.TypeError("time.struct_time() takes a 9-sequence (1-sequence given)");
            }
            return new PyTimeTuple((PyTuple) obj);
View Full Code Here

Examples of org.python.core.ArgParser

                return new PyTuple(result);
        }
    }

    public PyObject groups(PyObject[] args, String[] kws) {
        ArgParser ap = new ArgParser("groups", args, kws, "default");
        PyObject def = ap.getPyObject(0, Py.None);

        PyObject[] result = new PyObject[groups - 1];
        for (int i = 1; i < groups; i++) {
            result[i - 1] = getslice_by_index(i, def);
        }
View Full Code Here

Examples of org.python.core.ArgParser

        }
        return new PyTuple(result);
    }

    public PyObject groupdict(PyObject[] args, String[] kws) {
        ArgParser ap = new ArgParser("groupdict", args, kws, "default");
        PyObject def = ap.getPyObject(0, Py.None);

        PyObject result = new PyDictionary();

        if (pattern.groupindex == null)
            return result;
View Full Code Here

Examples of org.python.core.ArgParser

    }

    @ExposedNew
    static final PyObject weakref___new__(PyNewWrapper new_, boolean init, PyType subtype,
                                          PyObject[] args, String[] keywords) {
        ArgParser ap = parseInitArgs("__new__", args, keywords);
        PyObject ob = ap.getPyObject(0);
        PyObject callback = ap.getPyObject(1, null);
        if (callback == Py.None) {
            callback = null;
        }

        GlobalRef gref = GlobalRef.newInstance(ob);
View Full Code Here

Examples of org.python.core.ArgParser

    }

    @ExposedMethod
    final void weakref___init__(PyObject[] args, String[] keywords) {
        // Just ensure at least one arg, leaving other args alone
        ArgParser ap = parseInitArgs("__init__", args, keywords);
        ap.getPyObject(0);
    }
View Full Code Here

Examples of org.python.core.ArgParser

            int argc = args.length - keywords.length;
            PyObject[] justArgs = new PyObject[argc];
            System.arraycopy(args, 0, justArgs, 0, argc);
            args = justArgs;
        }
        return new ArgParser(funcName, args, Py.NoKeywords, Py.NoKeywords);
    }
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.