Search in sources :

Example 1 with AbstractCommand

use of com.bluenimble.platform.cli.command.impls.AbstractCommand in project serverless by bluenimble.

the class EndLnParser method main.

public static void main(String[] args) throws CommandParsingError {
    String cmdLine = "  -s   -f   argF -a rg2  -q select * \n from \n where 1=1";
    AbstractCommand command = new AbstractCommand("abc", "desc", "s,f++,!q+") {

        private static final long serialVersionUID = 0L;

        @Override
        public CommandResult execute(Tool tool, Map<String, CommandOption> options) throws CommandExecutionException {
            return null;
        }
    };
    CommandParser wrapper = new CommandParserImpl();
    Map<String, CommandOption> res = wrapper.parse(command, cmdLine);
    Iterator<CommandOption> optionsIter = res.values().iterator();
    while (optionsIter.hasNext()) {
        System.out.print(optionsIter.next());
    }
}
Also used : CommandOption(com.bluenimble.platform.cli.command.CommandOption) AbstractCommand(com.bluenimble.platform.cli.command.impls.AbstractCommand) CommandParserImpl(com.bluenimble.platform.cli.command.parser.impls.CommandParserImpl) Map(java.util.Map) Tool(com.bluenimble.platform.cli.Tool) CommandParser(com.bluenimble.platform.cli.command.parser.CommandParser)

Example 2 with AbstractCommand

use of com.bluenimble.platform.cli.command.impls.AbstractCommand in project serverless by bluenimble.

the class NoOptionsParser method main.

public static void main(String[] args) throws CommandParsingError {
    String cmdLine = "  -s   -f   argF -a rg2  -mult arg1 -";
    AbstractCommand command = new AbstractCommand("abc", "desc") {

        private static final long serialVersionUID = 0L;

        @Override
        public CommandResult execute(Tool tool, Map<String, CommandOption> options) throws CommandExecutionException {
            return null;
        }

        @Override
        public Map<String, CommandOption> getOptions() {
            return null;
        }
    };
    CommandParser wrapper = new CommandParserImpl();
    Map<String, CommandOption> res = wrapper.parse(command, cmdLine);
    if (res != null) {
        Iterator<CommandOption> optionsIter = res.values().iterator();
        while (optionsIter.hasNext()) {
            System.out.print(optionsIter.next());
        }
    }
}
Also used : CommandOption(com.bluenimble.platform.cli.command.CommandOption) AbstractCommand(com.bluenimble.platform.cli.command.impls.AbstractCommand) CommandParserImpl(com.bluenimble.platform.cli.command.parser.impls.CommandParserImpl) Map(java.util.Map) Tool(com.bluenimble.platform.cli.Tool) CommandParser(com.bluenimble.platform.cli.command.parser.CommandParser)

Example 3 with AbstractCommand

use of com.bluenimble.platform.cli.command.impls.AbstractCommand in project serverless by bluenimble.

the class SimpleParser method main.

public static void main(String[] args) throws CommandParsingError {
    String cmdLine = "-k teta -p beta";
    AbstractCommand command = new AbstractCommand("use", "desc", "k+,p+") {

        private static final long serialVersionUID = 0L;

        @Override
        public CommandResult execute(Tool tool, Map<String, CommandOption> options) throws CommandExecutionException {
            return null;
        }
    };
    CommandParser parser = new CommandParserImpl();
    Iterator<CommandOption> optionsIter = parser.parse(command, cmdLine).values().iterator();
    while (optionsIter.hasNext()) {
        System.out.println(optionsIter.next());
    }
}
Also used : CommandOption(com.bluenimble.platform.cli.command.CommandOption) AbstractCommand(com.bluenimble.platform.cli.command.impls.AbstractCommand) CommandParserImpl(com.bluenimble.platform.cli.command.parser.impls.CommandParserImpl) Map(java.util.Map) Tool(com.bluenimble.platform.cli.Tool) CommandParser(com.bluenimble.platform.cli.command.parser.CommandParser)

Example 4 with AbstractCommand

use of com.bluenimble.platform.cli.command.impls.AbstractCommand in project serverless by bluenimble.

the class TypedOptionParser method main.

public static void main(String[] args) throws CommandParsingError {
    String cmdLine = "  -s   -f   argF -a rg2  -multi arg1 -";
    AbstractCommand command = new AbstractCommand("abc", "desc", "s,f+,!multi+") {

        private static final long serialVersionUID = 0L;

        @Override
        public CommandResult execute(Tool tool, Map<String, CommandOption> options) throws CommandExecutionException {
            return null;
        }
    };
    command.getOptions().get("f").setCast(CommandOptionCast.Integer);
    CommandParser parser = new CommandParserImpl();
    Iterator<CommandOption> optionsIter = parser.parse(command, cmdLine).values().iterator();
    while (optionsIter.hasNext()) {
        System.out.println(optionsIter.next());
    }
}
Also used : CommandOption(com.bluenimble.platform.cli.command.CommandOption) AbstractCommand(com.bluenimble.platform.cli.command.impls.AbstractCommand) CommandParserImpl(com.bluenimble.platform.cli.command.parser.impls.CommandParserImpl) Map(java.util.Map) Tool(com.bluenimble.platform.cli.Tool) CommandParser(com.bluenimble.platform.cli.command.parser.CommandParser)

Aggregations

Tool (com.bluenimble.platform.cli.Tool)4 CommandOption (com.bluenimble.platform.cli.command.CommandOption)4 AbstractCommand (com.bluenimble.platform.cli.command.impls.AbstractCommand)4 CommandParser (com.bluenimble.platform.cli.command.parser.CommandParser)4 CommandParserImpl (com.bluenimble.platform.cli.command.parser.impls.CommandParserImpl)4 Map (java.util.Map)4