Example #1
0
  @Override
  public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

    for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
      if (!scriptEntry.hasObject("type")
          && arg.matchesPrefix("type")
          && arg.matchesEnum(Type.values())) scriptEntry.addObject("type", arg.asElement());
      else if (!scriptEntry.hasObject("file") && arg.matchesPrefix("file"))
        scriptEntry.addObject("file", arg.asElement());
      else if (!scriptEntry.hasObject("message")) scriptEntry.addObject("message", arg.asElement());
      else arg.reportUnhandled();
    }

    if (!scriptEntry.hasObject("message"))
      throw new InvalidArgumentsException("Must specify a message.");

    if (!scriptEntry.hasObject("file")) throw new InvalidArgumentsException("Must specify a file.");

    if (!scriptEntry.hasObject("type")) scriptEntry.addObject("type", new Element("INFO"));
  }