Search in sources :

Example 6 with ArgumentParser

use of net.morimekta.console.args.ArgumentParser in project providence by morimekta.

the class ConfigOptions method getArgumentParser.

@Override
public ArgumentParser getArgumentParser(String prog, String description) throws IOException {
    ArgumentParser parser = super.getArgumentParser(prog, description);
    parser.add(new Flag("--strict", "S", "Parse config strictly", this::setStrict, false));
    parser.add(new Option("--include", "I", "dir", "Read config definitions from these directories.", dir(includes::add), null, true, false, false));
    commandSet = new SubCommandSet<>("cmd", "Config action.", this::setCommand, null, true, getArgumentOptions());
    commandSet.add(new SubCommand<>("help", "Show help for sub-commands.", false, () -> new Help(commandSet, parser), cmd -> cmd.parser(parser)));
    commandSet.add(new SubCommand<>("resolve", "Resolve the resulting config.", false, Resolve::new, cmd -> cmd.parser(parser), "p", "pr"));
    commandSet.add(new SubCommand<>("validate", "Validate the files, print error if not valid.", false, Validate::new, cmd -> cmd.parser(parser)));
    parser.add(commandSet);
    return parser;
}
Also used : ArgumentParser(net.morimekta.console.args.ArgumentParser) Parser.dir(net.morimekta.console.util.Parser.dir) SubCommandSet(net.morimekta.console.args.SubCommandSet) CommonOptions(net.morimekta.providence.tools.common.CommonOptions) IOException(java.io.IOException) Command(net.morimekta.providence.tools.config.cmd.Command) Help(net.morimekta.providence.tools.config.cmd.Help) File(java.io.File) ArrayList(java.util.ArrayList) Validate(net.morimekta.providence.tools.config.cmd.Validate) Flag(net.morimekta.console.args.Flag) List(java.util.List) STTY(net.morimekta.console.util.STTY) Resolve(net.morimekta.providence.tools.config.cmd.Resolve) Option(net.morimekta.console.args.Option) SubCommand(net.morimekta.console.args.SubCommand) Help(net.morimekta.providence.tools.config.cmd.Help) Option(net.morimekta.console.args.Option) ArgumentParser(net.morimekta.console.args.ArgumentParser) Flag(net.morimekta.console.args.Flag)

Example 7 with ArgumentParser

use of net.morimekta.console.args.ArgumentParser in project providence by morimekta.

the class CommonOptions method getArgumentParser.

public ArgumentParser getArgumentParser(String prog, String description) throws IOException {
    ArgumentParser parser = new ArgumentParser(prog, Utils.getVersionString(), description, getArgumentOptions());
    parser.add(new Flag("--help", "h?", "This help listing.", this::setHelp));
    parser.add(new Flag("--verbose", "V", "Show verbose output and error messages.", this::setVerbose));
    parser.add(new Flag("--version", "v", "Show program version.", this::setVersion));
    parser.add(new Option("--rc", null, "FILE", "Providence RC to use", file(this::setRc), "~" + File.separator + ".pvdrc"));
    return parser;
}
Also used : Option(net.morimekta.console.args.Option) ArgumentParser(net.morimekta.console.args.ArgumentParser) Flag(net.morimekta.console.args.Flag)

Example 8 with ArgumentParser

use of net.morimekta.console.args.ArgumentParser in project providence by morimekta.

the class Help method parser.

@Override
public ArgumentParser parser(ArgumentParser parent) {
    ArgumentParser parser = new ArgumentParser(parent.getProgram() + " [...] help", parent.getVersion(), "");
    parser.add(new Argument("cmd", "Command to show help for", this::setCommand, null, null, false, false, false));
    return parser;
}
Also used : Argument(net.morimekta.console.args.Argument) ArgumentParser(net.morimekta.console.args.ArgumentParser)

Example 9 with ArgumentParser

use of net.morimekta.console.args.ArgumentParser 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;
}
Also used : Argument(net.morimekta.console.args.Argument) Option(net.morimekta.console.args.Option) ArgumentParser(net.morimekta.console.args.ArgumentParser)

Example 10 with ArgumentParser

use of net.morimekta.console.args.ArgumentParser in project providence by morimekta.

the class Validate method parser.

@Override
public ArgumentParser parser(ArgumentParser parent) {
    ArgumentParser parser = new ArgumentParser(parent.getProgram() + " [...] validate", parent.getVersion(), "Verify content of config files, also checking includes");
    parser.add(new Argument("file", "Config files to validate", Parser.file(this::addFile), null, null, true, true, false));
    return parser;
}
Also used : Argument(net.morimekta.console.args.Argument) ArgumentParser(net.morimekta.console.args.ArgumentParser)

Aggregations

ArgumentParser (net.morimekta.console.args.ArgumentParser)13 IOException (java.io.IOException)8 Argument (net.morimekta.console.args.Argument)7 ArgumentException (net.morimekta.console.args.ArgumentException)7 Option (net.morimekta.console.args.Option)7 Flag (net.morimekta.console.args.Flag)6 File (java.io.File)4 STTY (net.morimekta.console.util.STTY)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Parser.dir (net.morimekta.console.util.Parser.dir)3 PService (net.morimekta.providence.descriptor.PService)3 MessageReader (net.morimekta.providence.mio.MessageReader)3 MessageWriter (net.morimekta.providence.mio.MessageWriter)3 TypeLoader (net.morimekta.providence.reflect.TypeLoader)3 ParseException (net.morimekta.providence.reflect.parser.ParseException)3 UncheckedIOException (java.io.UncheckedIOException)2 Map (java.util.Map)2 Parser.file (net.morimekta.console.util.Parser.file)2 PServiceCall (net.morimekta.providence.PServiceCall)2