@Override public int size() { return params.size()-1; } });
@Override public int size() { return params.size()-1; } });
/** * Tries to parse {@code String[]} argument from {@link Parameters}. */ @Override public int parseArguments(Parameters params) throws CmdLineException { int counter=0; for (; counter<params.size(); counter++) { String param = params.getParameter(counter); if(param.startsWith("-")) { break; } for (String p : param.split(" ")) { setter.addValue(p); } } return counter; }
/** * Tries to parse {@code String[]} argument from {@link Parameters}. */ @Override public int parseArguments(Parameters params) throws CmdLineException { int counter=0; for (; counter<params.size(); counter++) { String param = params.getParameter(counter); if(param.startsWith("-")) { break; } for (String p : param.split(" ")) { setter.addValue(p); } } return counter; }
@Override public int parseArguments(Parameters params) throws CmdLineException { // end of arg list or next arg is another option if ((params.size() == 0) || params.getParameter(0).startsWith("-")) { setter.addValue(TRUE); return 0; } else { setter.addValue(getBoolean(params.getParameter(0))); return 1; } }
@Override public int parseArguments(Parameters params) throws CmdLineException { // end of arg list or next arg is another option if ((params.size() == 0) || params.getParameter(0).startsWith("-")) { setter.addValue(TRUE); return 0; } else { setter.addValue(getBoolean(params.getParameter(0))); return 1; } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
@Override public int size() { return params.size()-1; } });
@Override public int size() { return params.size() - 1; } });
@Override public int parseArguments(Parameters parameters) throws CmdLineException { List<File> sourceFiles = new ArrayList<File>(parameters.size()); for(int i = 0; i<parameters.size(); i++) { String sourcePath = parameters.getParameter(i); // be tolerant, accept also '/' as file separator File sourceFile = new File(sourcePath.replace('/', File.separatorChar)); if (!sourceFile.exists()) { throw new CmdLineException(owner, "Source file does not exist: " + sourceFile.getAbsolutePath()); } sourceFiles.add(sourceFile); } setter.addValue(sourceFiles); return parameters.size(); }
@Override public int parseArguments(Parameters params) throws CmdLineException { final int paramsSize = params.size(); for (int i = 0; i < paramsSize; i++) { String param = params.getParameter(i); if (param.startsWith("-")) { return i; } setter.addValue(param); } return paramsSize; } }
@Override public int parseArguments(Parameters params) throws CmdLineException { if (params.size() != 1) throw new CmdLineException ("an option of type log level should have one parameter [trace,debug,info,warn,error,fatal,off]"); Level result = Level.toLevel(params.getParameter(0).toLowerCase()); setter.addValue(result); log.debug("set log level " + result); return 1; }
/** * Tries to parse {@code String[]} argument from {@link Parameters}. */ @Override public int parseArguments(Parameters params) throws CmdLineException { int counter=0; for (; counter<params.size(); counter++) { String param = params.getParameter(counter); if(param.startsWith("-")) { break; } for (String p : param.split(" ")) { setter.addValue(p); } } return counter; }
@Override public int parseArguments(Parameters params) throws CmdLineException { // end of arg list or next arg is another option if ((params.size() == 0) || params.getParameter(0).startsWith("-")) { setter.addValue(TRUE); return 0; } else { setter.addValue(getBoolean(params.getParameter(0))); return 1; } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
@Override public int parseArguments(final Parameters params) throws CmdLineException { final String subCmd = params.getParameter(0); for (final Command c : AllCommands.get()) { if (c.name().equals(subCmd)) { parseSubArguments(c, params); setter.addValue(c); return params.size(); // consume all the remaining tokens } } throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND.format(option.toString(), subCmd)); }