Search in sources :

Example 1 with IWalleCommand

use of com.meituan.android.walle.commands.IWalleCommand in project walle by Meituan-Dianping.

the class Main method main.

public static void main(final String[] args) throws Exception {
    final Map<String, IWalleCommand> subCommandList = new HashMap<String, IWalleCommand>();
    subCommandList.put("show", new ShowCommand());
    subCommandList.put("rm", new RemoveCommand());
    subCommandList.put("put", new WriteChannelCommand());
    subCommandList.put("batch", new WriteChannelsCommand());
    final WalleCommandLine walleCommandLine = new WalleCommandLine();
    final JCommander commander = new JCommander(walleCommandLine);
    for (Map.Entry<String, IWalleCommand> commandEntry : subCommandList.entrySet()) {
        commander.addCommand(commandEntry.getKey(), commandEntry.getValue());
    }
    try {
        commander.parse(args);
    } catch (ParameterException e) {
        System.out.println(e.getMessage());
        commander.usage();
        System.exit(1);
        return;
    }
    walleCommandLine.parse(commander);
    final String parseCommand = commander.getParsedCommand();
    if (parseCommand != null) {
        subCommandList.get(parseCommand).parse();
    }
}
Also used : RemoveCommand(com.meituan.android.walle.commands.RemoveCommand) WriteChannelsCommand(com.meituan.android.walle.commands.WriteChannelsCommand) HashMap(java.util.HashMap) IWalleCommand(com.meituan.android.walle.commands.IWalleCommand) JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) ShowCommand(com.meituan.android.walle.commands.ShowCommand) WriteChannelCommand(com.meituan.android.walle.commands.WriteChannelCommand) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 IWalleCommand (com.meituan.android.walle.commands.IWalleCommand)1 RemoveCommand (com.meituan.android.walle.commands.RemoveCommand)1 ShowCommand (com.meituan.android.walle.commands.ShowCommand)1 WriteChannelCommand (com.meituan.android.walle.commands.WriteChannelCommand)1 WriteChannelsCommand (com.meituan.android.walle.commands.WriteChannelsCommand)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1