protected void buildPython(IndentingAppender ia) throws IOException { String name = getClass().getSimpleName(); ia.append("def ").append(name).append("(self"); ia.incrementIndent().incrementIndent(); for (Argument arg : _arguments) { ia.append(", ").append(arg._name); if (!arg._required) ia.append("=None"); } ia.appendln("):"); ia.decrementIndent().decrementIndent(); ia.incrementIndent(); ia.appendln("'''"); ia.appendln(Objects.firstNonNull(_requestHelp, "MISSING HELP STRING")); if (!_arguments.isEmpty()) ia.appendln("Arguments:"); ia.incrementIndent(); for (Argument arg : _arguments) { ia.append(arg._name).append(" -- "); if (arg._required) ia.append("required -- "); ia.appendln(arg.queryDescription()); ia.incrementIndent(); ia.appendln(Objects.firstNonNull(arg._requestHelp, "MISSING HELP STRING")); ia.decrementIndent(); } ia.decrementIndent(); ia.appendln("'''"); ia.appendln("pass"); ia.decrementIndent(); }
protected JsonObject serveHelp() { JsonObject r = new JsonObject(); r.addProperty(NAME, getClass().getSimpleName()); r.addProperty(DESCRIPTION, _requestHelp); JsonArray args = new JsonArray(); for (Argument arg : _arguments) { args.add(arg.requestHelp()); } r.add(ARGUMENTS, args); return r; }
protected static final void help(Argument arg, String help) { arg._requestHelp = help; }