@Override public boolean isFlagEnabled(String name) { Option option = cli.getOption(name); if (option == null) { throw new IllegalArgumentException("Cannot find the option '" + name + "'"); } if (option.isFlag()) { return optionsSeenInCommandLine.contains(option); } else { throw new IllegalStateException("Cannot retrieve the flag value on a non-flag option (" + name + ")"); } }
public DefaultCommandLine addRawValue(Option option, String value) { if (!acceptMoreValues(option) && !option.isFlag()) { throw new CLIException("The option " + option.getName() + " does not accept value or has " + "already been set"); } if (! option.getChoices().isEmpty() && ! option.getChoices().contains(value)) { throw new InvalidValueException(option, value); } List<String> list = optionValues.get(option); if (list == null) { list = new ArrayList<>(); optionValues.put(option, list); } list.add(value); return this; }
private void checkRequiredValues() throws MissingValueException { if (current != null) { if (current.acceptValue() && !commandLine.isOptionAssigned(current) && !current.isFlag()) { throw new MissingValueException(current); } } }
json.put("description", obj.getDescription()); json.put("flag", obj.isFlag()); json.put("help", obj.isHelp()); json.put("hidden", obj.isHidden());
@Override public boolean isFlagEnabled(String name) { Option option = cli.getOption(name); if (option == null) { throw new IllegalArgumentException("Cannot find the option '" + name + "'"); } if (option.isFlag()) { return optionsSeenInCommandLine.contains(option); } else { throw new IllegalStateException("Cannot retrieve the flag value on a non-flag option (" + name + ")"); } }
public DefaultCommandLine addRawValue(Option option, String value) { if (!acceptMoreValues(option) && !option.isFlag()) { throw new CLIException("The option " + option.getName() + " does not accept value or has " + "already been set"); } if (! option.getChoices().isEmpty() && ! option.getChoices().contains(value)) { throw new InvalidValueException(option, value); } List<String> list = optionValues.get(option); if (list == null) { list = new ArrayList<>(); optionValues.put(option, list); } list.add(value); return this; }
private void checkRequiredValues() throws MissingValueException { if (current != null) { if (current.acceptValue() && !commandLine.isOptionAssigned(current) && !current.isFlag()) { throw new MissingValueException(current); } } }
assertEquals(copy.getDefaultValue(), option.getDefaultValue()); assertEquals(copy.getDescription(), option.getDescription()); assertEquals(copy.isFlag(), option.isFlag()); assertEquals(copy.isHelp(), option.isHelp()); assertEquals(copy.isHidden(), option.isHidden()); assertEquals(copy.getDefaultValue(), option.getDefaultValue()); assertEquals(copy.getDescription(), option.getDescription()); assertEquals(copy.isFlag(), option.isFlag()); assertEquals(copy.isHelp(), option.isHelp()); assertEquals(copy.isHidden(), option.isHidden());
json.put("description", obj.getDescription()); json.put("flag", obj.isFlag()); json.put("help", obj.isHelp()); json.put("hidden", obj.isHidden());
assertEquals(copy.getDefaultValue(), option.getDefaultValue()); assertEquals(copy.getDescription(), option.getDescription()); assertEquals(copy.isFlag(), option.isFlag()); assertEquals(copy.isHelp(), option.isHelp()); assertEquals(copy.isHidden(), option.isHidden()); assertEquals(copy.getDefaultValue(), option.getDefaultValue()); assertEquals(copy.getDescription(), option.getDescription()); assertEquals(copy.isFlag(), option.isFlag()); assertEquals(copy.isHelp(), option.isHelp()); assertEquals(copy.isHidden(), option.isHidden());