@Test public void lsM() throws Exception { PlungerArguments pa = merge("provider: assertMisc(pa, "ls", true, false); assertTarget(pa, "provider", "host", 1234, null, null, "queue.destination", "destination"); assertFalse(pa.containsCommandArgument("c")); assertFalse(pa.containsCommandArgument("consumer")); assertTrue(pa.containsCommandArgument("m")); assertTrue(pa.containsCommandArgument("messages")); }
public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception { PlungerArguments result = new PlungerArguments(); Target commandTarget = new TargetParser().parse(cmdTarget); Entry entry = config.getEntry(commandTarget.getHost()); if ((entry != null) && (entry.getTarget() != null)) { result.setTarget(mergeTarget(commandTarget, entry.getTarget())); } else { result.setTarget(commandTarget); } result.setColors(mergeColors(line, result, entry)); result.setVerbose(line.hasOption("verbose")); result.setCommand(line.getOptionValue("command")); for (Object opt: options.getOptions()) { Option option = (Option)opt; if (option.getOpt() != null && line.hasOption(option.getOpt())) { String value = join(line.getOptionValues(option.getOpt()), " "); result.addCommandArgument(option.getOpt(), value); result.addCommandArgument(option.getLongOpt(), value); } } return result; }
ArgumentMerger { public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception { PlungerArguments result = new PlungerArguments(); Target commandTarget = new TargetParser().parse(cmdTarget); Entry entry = config.getEntry(commandTarget.getHost()); if ((entry != null) && (entry.getTarget() != null)) { result.setTarget(mergeTarget(commandTarget, entry.getTarget())); } else { result.setTarget(commandTarget); } result.setColors(mergeColors(line, result, entry)); result.setVerbose(line.hasOption("verbose")); result.setCommand(line.getOptionValue("command")); for (Object opt: options.getOptions()) { Option option = (Option)opt; if (option.getOpt() != null && line.hasOption(option.getOpt())) { String value = join(line.getOptionValues(option.getOpt()), " "); result.addCommandArgument(option.getOpt(), value); result.addCommandArgument(option.getLongOpt(), value); } } return result; } }
ArgumentMerger { public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception { PlungerArguments result = new PlungerArguments(); Target commandTarget = new TargetParser().parse(cmdTarget); Entry entry = config.getEntry(commandTarget.getHost()); if ((entry != null) && (entry.getTarget() != null)) { result.setTarget(mergeTarget(commandTarget, entry.getTarget())); } else { result.setTarget(commandTarget); } result.setColors(mergeColors(line, result, entry)); result.setVerbose(line.hasOption("verbose")); result.setCommand(line.getOptionValue("command")); for (Object opt: options.getOptions()) { Option option = (Option)opt; if (option.getOpt() != null && line.hasOption(option.getOpt())) { String value = join(line.getOptionValues(option.getOpt()), " "); result.addCommandArgument(option.getOpt(), value); result.addCommandArgument(option.getLongOpt(), value); } } return result; }  }
ArgumentMerger { public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception { PlungerArguments result = new PlungerArguments(); Target commandTarget = new TargetParser().parse(cmdTarget); Entry entry = config.getEntry(commandTarget.getHost()); if ((entry != null) && (entry.getTarget() != null)) { result.setTarget(mergeTarget(commandTarget, entry.getTarget())); } else { result.setTarget(commandTarget); } result.setColors(mergeColors(line, result, entry)); result.setVerbose(line.hasOption("verbose")); result.setCommand(line.getOptionValue("command")); for (Object opt: options.getOptions()) { Option option = (Option)opt; if (option.getOpt() != null && line.hasOption(option.getOpt())) { String value = join(line.getOptionValues(option.getOpt()), " "); result.addCommandArgument(option.getOpt(), value); result.addCommandArgument(option.getLongOpt(), value); } } return result; }  PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options); }
ArgumentMerger { public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception { PlungerArguments result = new PlungerArguments(); Target commandTarget = new TargetParser().parse(cmdTarget); Entry entry = config.getEntry(commandTarget.getHost()); if ((entry != null) && (entry.getTarget() != null)) { result.setTarget(mergeTarget(commandTarget, entry.getTarget())); } else { result.setTarget(commandTarget); } result.setColors(mergeColors(line, result, entry)); result.setVerbose(line.hasOption("verbose")); result.setCommand(line.getOptionValue("command")); for (Object opt: options.getOptions()) { Option option = (Option)opt; if (option.getOpt() != null && line.hasOption(option.getOpt())) { String value = join(line.getOptionValues(option.getOpt()), " "); result.addCommandArgument(option.getOpt(), value); result.addCommandArgument(option.getLongOpt(), value); } } return result; }  PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options);  }