@Override protected void execute(Terminal terminal, OptionSet options) throws Exception { final Map<String, String> settings = new HashMap<>(); for (final KeyValuePair kvp : settingOption.values(options)) { if (kvp.value.isEmpty()) { throw new UserException(ExitCodes.USAGE, "setting [" + kvp.key + "] must not be empty"); } if (settings.containsKey(kvp.key)) { final String message = String.format( Locale.ROOT, "setting [%s] already set, saw [%s] and [%s]", kvp.key, settings.get(kvp.key), kvp.value); throw new UserException(ExitCodes.USAGE, message); } settings.put(kvp.key, kvp.value); } putSystemPropertyIfSettingIsMissing(settings, "path.data", "es.path.data"); putSystemPropertyIfSettingIsMissing(settings, "path.home", "es.path.home"); putSystemPropertyIfSettingIsMissing(settings, "path.logs", "es.path.logs"); execute(terminal, options, createEnv(terminal, settings)); }
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { List<String> settings = arguments.values(options); if (settings.isEmpty()) { throw new UserException(ExitCodes.USAGE, "Must supply at least one setting to remove"); } KeyStoreWrapper keystore = KeyStoreWrapper.load(env.configFile()); if (keystore == null) { throw new UserException(ExitCodes.DATA_ERROR, "Elasticsearch keystore not found. Use 'create' command to create one."); } keystore.decrypt(new char[0] /* TODO: prompt for password when they are supported */); for (String setting : arguments.values(options)) { if (keystore.getSettingNames().contains(setting) == false) { throw new UserException(ExitCodes.CONFIG, "Setting [" + setting + "] does not exist in the keystore."); } keystore.remove(setting); } keystore.save(env.configFile(), new char[0]); } }
List<String> argumentValues = arguments.values(options); if (argumentValues.size() == 0) { throw new UserException(ExitCodes.USAGE, "Missing setting name");
public List<String> getNonOptions(){ return nonOption.values(options); }
public List<String> getNonOptions(){ return nonOption.values(options); }
data.setTestPlugin(userArgs.valueOf(this.testPluginSpec)); data.setReportDir(userArgs.valueOf(this.reportDirSpec)); data.setTargetClasses(this.targetClassesSpec.values(userArgs)); data.setTargetTests(FCollection.map(this.targetTestsSpec.values(userArgs), Glob.toGlobPredicate())); data.setSourceDirs(this.sourceDirSpec.values(userArgs)); data.setMutators(this.mutators.values(userArgs)); data.setFeatures(this.features.values(userArgs)); data.setDependencyAnalysisMaxDistance(this.depth.value(userArgs)); data.addChildJVMArgs(this.jvmArgs.values(userArgs)); data.setTimeoutFactor(this.timeoutFactorSpec.value(userArgs)); data.setTimeoutConstant(this.timeoutConstSpec.value(userArgs)); data.setLoggingClasses(this.avoidCallsSpec.values(userArgs)); data.setExcludedMethods(this.excludedMethodsSpec.values(userArgs)); data.setExcludedClasses(this.excludedClassesSpec.values(userArgs)); data.setExcludedTestClasses(FCollection.map( this.excludedTestClassesSpec.values(userArgs), Glob.toGlobPredicate())); data.setVerbose(userArgs.has(this.verboseSpec) && userArgs.valueOf(this.verboseSpec)); data.addOutputFormats(this.outputFormatSpec.values(userArgs)); data.setFailWhenNoMutations(this.failWhenNoMutations.value(userArgs)); data.setCodePaths(this.codePaths.values(userArgs)); data.setMutationEngine(this.mutationEngine.value(userArgs)); data.setFreeFormProperties(listToProperties(this.pluginPropertiesSpec .values(userArgs)));
public String[] getSysProperties(){ return this.sysPropOptions.values(this.optionSet).toArray(new String[]{}); }
public String[] getXValues(){ return this.xVmOptions.values(this.optionSet).toArray(new String[]{}); }
public String getStoreArg() { List<String> nonOptions = nonOption.values(options); return nonOptions.size() > 0 ? nonOptions.get(0) : ""; }
public String getStoreArg() { List<String> nonOptions = nonOption.values(options); return nonOptions.size() > 0 ? nonOptions.get(0) : ""; }
@Override protected void execute(Terminal terminal, OptionSet options) throws Exception { final Map<String, String> settings = new HashMap<>(); for (final KeyValuePair kvp : settingOption.values(options)) { if (kvp.value.isEmpty()) { throw new UserException(ExitCodes.USAGE, "setting [" + kvp.key + "] must not be empty"); } if (settings.containsKey(kvp.key)) { final String message = String.format( Locale.ROOT, "setting [%s] already set, saw [%s] and [%s]", kvp.key, settings.get(kvp.key), kvp.value); throw new UserException(ExitCodes.USAGE, message); } settings.put(kvp.key, kvp.value); } putSystemPropertyIfSettingIsMissing(settings, "path.data", "es.path.data"); putSystemPropertyIfSettingIsMissing(settings, "path.home", "es.path.home"); putSystemPropertyIfSettingIsMissing(settings, "path.logs", "es.path.logs"); execute(terminal, options, createEnv(terminal, settings)); }
/** * * @param line */ public ExecJavaCliParser(String line){ this.optionParser = new OptionParser("D:X:"); this.optionParser.allowsUnrecognizedOptions(); this.xVmOptions = this.optionParser.accepts("X").withRequiredArg(); this.sysPropOptions = this.optionParser.accepts("D").withRequiredArg(); this.mainArgumentsOptions = this.optionParser.nonOptions(); this.optionSet = this.optionParser.parse(line.split(" ")); Pattern p = Pattern.compile("([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*"); this.mainArguments = new ArrayList<String>(this.mainArgumentsOptions.values(this.optionSet)); Iterator<String> mainArgumentsIter = this.mainArguments.iterator(); boolean mainFound = false; while (mainArgumentsIter.hasNext()){ String value = mainArgumentsIter.next(); Matcher m = p.matcher(value); boolean matches = m.matches(); if (matches && !mainFound){ mainFound = true; this.main = value; mainArgumentsIter.remove(); break; } else if (!mainFound){ mainArgumentsIter.remove(); } } }
@Override protected void execute(Terminal terminal, OptionSet options) throws Exception { final Map<String, String> settings = new HashMap<>(); for (final KeyValuePair kvp : settingOption.values(options)) { if (kvp.value.isEmpty()) { throw new UserException(ExitCodes.USAGE, "setting [" + kvp.key + "] must not be empty"); } if (settings.containsKey(kvp.key)) { final String message = String.format( Locale.ROOT, "setting [%s] already set, saw [%s] and [%s]", kvp.key, settings.get(kvp.key), kvp.value); throw new UserException(ExitCodes.USAGE, message); } settings.put(kvp.key, kvp.value); } putSystemPropertyIfSettingIsMissing(settings, "path.data", "es.path.data"); putSystemPropertyIfSettingIsMissing(settings, "path.home", "es.path.home"); putSystemPropertyIfSettingIsMissing(settings, "path.logs", "es.path.logs"); execute(terminal, options, createEnv(terminal, settings)); }
@Override protected void execute(Terminal terminal, OptionSet options) throws Exception { final Map<String, String> settings = new HashMap<>(); for (final KeyValuePair kvp : settingOption.values(options)) { if (kvp.value.isEmpty()) { throw new UserException(ExitCodes.USAGE, "setting [" + kvp.key + "] must not be empty"); } if (settings.containsKey(kvp.key)) { final String message = String.format( Locale.ROOT, "setting [%s] already set, saw [%s] and [%s]", kvp.key, settings.get(kvp.key), kvp.value); throw new UserException(ExitCodes.USAGE, message); } settings.put(kvp.key, kvp.value); } putSystemPropertyIfSettingIsMissing(settings, "path.conf", "es.path.conf"); putSystemPropertyIfSettingIsMissing(settings, "path.data", "es.path.data"); putSystemPropertyIfSettingIsMissing(settings, "path.home", "es.path.home"); putSystemPropertyIfSettingIsMissing(settings, "path.logs", "es.path.logs"); execute(terminal, options, createEnv(terminal, settings)); }
private Collection<String> processArgs(OptionSpec<String> op, OptionSet set) { if (set.hasArgument(op)) { try { List<String> vals = op.values(set); if (vals.size() != 1) { return vals; } else { return StringUtils.splitQuotedEscape(op.value(set)); } } catch (OptionException e) { return StringUtils.splitQuotedEscape(op.value(set)); } } else { return null; } }
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { List<String> settings = arguments.values(options); if (settings.isEmpty()) { throw new UserException(ExitCodes.USAGE, "Must supply at least one setting to remove"); } KeyStoreWrapper keystore = KeyStoreWrapper.load(env.configFile()); if (keystore == null) { throw new UserException(ExitCodes.DATA_ERROR, "Elasticsearch keystore not found. Use 'create' command to create one."); } keystore.decrypt(new char[0] /* TODO: prompt for password when they are supported */); for (String setting : arguments.values(options)) { if (keystore.getSettingNames().contains(setting) == false) { throw new UserException(ExitCodes.CONFIG, "Setting [" + setting + "] does not exist in the keystore."); } keystore.remove(setting); } keystore.save(env.configFile(), new char[0]); } }
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { List<String> settings = arguments.values(options); if (settings.isEmpty()) { throw new UserException(ExitCodes.USAGE, "Must supply at least one setting to remove"); } KeyStoreWrapper keystore = KeyStoreWrapper.load(env.configFile()); if (keystore == null) { throw new UserException(ExitCodes.DATA_ERROR, "Elasticsearch keystore not found. Use 'create' command to create one."); } keystore.decrypt(new char[0] /* TODO: prompt for password when they are supported */); for (String setting : arguments.values(options)) { if (keystore.getSettingNames().contains(setting) == false) { throw new UserException(ExitCodes.CONFIG, "Setting [" + setting + "] does not exist in the keystore."); } keystore.remove(setting); } keystore.save(env.configFile()); } }
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { List<String> settings = arguments.values(options); if (settings.isEmpty()) { throw new UserException(ExitCodes.USAGE, "Must supply at least one setting to remove"); } KeyStoreWrapper keystore = KeyStoreWrapper.load(env.configFile()); if (keystore == null) { throw new UserException(ExitCodes.DATA_ERROR, "Elasticsearch keystore not found. Use 'create' command to create one."); } keystore.decrypt(new char[0] /* TODO: prompt for password when they are supported */); for (String setting : arguments.values(options)) { if (keystore.getSettingNames().contains(setting) == false) { throw new UserException(ExitCodes.CONFIG, "Setting [" + setting + "] does not exist in the keystore."); } keystore.remove(setting); } keystore.save(env.configFile(), new char[0]); } }
List<String> argumentValues = arguments.values(options); if (argumentValues.size() == 0) { throw new UserException(ExitCodes.USAGE, "Missing setting name");