use of net.morimekta.console.args.Option in project providence by morimekta.
the class Resolve method parser.
@Override
public ArgumentParser parser(ArgumentParser parent) {
ArgumentParser parser = new ArgumentParser(parent.getProgram() + " [...] resolve", parent.getVersion(), "Resolve config files to final config message.");
parser.add(new Option("--format", "f", "fmt", "the output format", this::setSerializer, "pretty"));
parser.add(new Argument("file", "Config files to resolve", Parser.file(this::addFile), null, null, true, true, false));
return parser;
}
use of net.morimekta.console.args.Option in project providence by morimekta.
the class RPCOptions method getArgumentParser.
@Override
public ArgumentParser getArgumentParser(String prog, String description) throws IOException {
ArgumentParser parser = super.getArgumentParser(prog, description);
parser.add(new Option("--include", "I", "dir", "Allow includes of files in directory", dir(this::addInclude), null, true, false, false));
parser.add(new Option("--in", "i", "spec", "Input specification", new ConvertStreamParser(in).andApply(this::setIn), in.toString()));
parser.add(new Option("--out", "o", "spec", "Output Specification", new ConvertStreamParser(out).andApply(this::setOut), out.toString()));
parser.add(new Option("--service", "s", "srv", "Qualified identifier name from definitions to use for parsing source file.", this::setService, null, false, true, false));
parser.add(new Option("--format", "f", "fmt", "Request RPC format", oneOf(Format.class, this::setFormat), format.name()));
parser.add(new Option("--connect_timeout", "C", "ms", "Connection timeout in milliseconds. 0 means infinite.", i32(this::setConnectTimeout), "10000"));
parser.add(new Option("--read_timeout", "R", "ms", "Request timeout in milliseconds. 0 means infinite.", i32(this::setReadTimeout), "10000"));
parser.add(new Option("--header", "H", "hdr", "Header to set on the request, K/V separated by ':'.", this::addHeaders, null, true, false, false));
parser.add(new Flag("--strict", "S", "Read incoming messages strictly.", this::setStrict));
parser.add(new Argument("URI", "The endpoint URI", this::setEndpoint, null, s -> {
try {
if (!s.contains("://"))
return false;
URI uri = new URI(s);
if (isNullOrEmpty(uri.getAuthority())) {
throw new ArgumentException("Missing authority in URI: '" + s + "'");
}
return true;
} catch (URISyntaxException e) {
throw new ArgumentException(e, e.getMessage());
}
}, false, true, false));
return parser;
}
Aggregations