Refine search
@Override public int parseArguments(Parameters params) throws CmdLineException { String param = params.getParameter(0); Result v = fromString(param.replace('-', '_')); if (v==null) throw new CmdLineException(owner,"No such status '"+param+"'. Did you mean "+ EditDistance.findNearest(param.replace('-', '_').toUpperCase(), getNames())); setter.addValue(v); return 1; }
public int parseArguments(Parameters parameters) throws CmdLineException { for (int i=0; i<parameters.size(); i++) setter.addValue(parameters.getParameter(i)); return parameters.size(); }
@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; }
@Override public int parseArguments(Parameters params) throws CmdLineException { String macString = params.getParameter(0); String[] macStringArray = null; throw new CmdLineException(owner, Messages.ILLEGAL_MAC_ADDRESS, macString); setter.asFieldSetter().addValue(mac); return 1;
@Override public int parseArguments(Parameters params) throws CmdLineException { setter.addValue(getView(params.getParameter(0))); return 1; }
@Override public int parseArguments(final Parameters params) throws CmdLineException { String name = params.getParameter(0); boolean interesting = true; if (name.startsWith("^")) { //$NON-NLS-1$ name = name.substring(1); interesting = false; } final int dot2 = name.indexOf(".."); //$NON-NLS-1$ if (dot2 != -1) { if (!option.isMultiValued()) throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn , option.metaVar(), name)); final String left = name.substring(0, dot2); final String right = name.substring(dot2 + 2); addOne(left, false); addOne(right, true); return 1; } addOne(name, interesting); return 1; }
@Override public int parseArguments(Parameters params) throws CmdLineException { FieldSetter fs = setter.asFieldSetter(); Map v = (Map)fs.getValue(); if (v==null) { v = createNewCollection(fs.getType()); fs.addValue(v); } addToMap(params.getParameter(0),v); return 1; }
@Override public String get(int index) { try { return params.getParameter(index+1); } catch (CmdLineException e) { // invalid index was accessed. throw new IndexOutOfBoundsException(); } }
@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 { String macString = params.getParameter(0); String[] macStringArray = null; throw new CmdLineException(owner, Messages.ILLEGAL_MAC_ADDRESS, macString); setter.asFieldSetter().addValue(mac); return 1;
@Override public int parseArguments(Parameters params) throws CmdLineException { String nodeName = params.getParameter(0); final Node node = Jenkins.get().getNode(nodeName); if (node == null) throw new IllegalArgumentException("No such node '" + nodeName + "'"); setter.addValue(node); return 1; }
@Override public int parseArguments(Parameters params) throws CmdLineException { FieldSetter fs = setter.asFieldSetter(); Map v = (Map)fs.getValue(); if (v==null) { v = createNewCollection(fs.getType()); fs.addValue(v); } addToMap(params.getParameter(0),v); return 1; }
@Override public String get(int index) { try { return params.getParameter(index+1); } catch (CmdLineException e) { // invalid index was accessed. throw new IndexOutOfBoundsException(); } }
@Override public int size() { return params.size()-1; } });
@Override public int parseArguments(Parameters params) throws CmdLineException { String param = params.getParameter(0); try { setter.addValue(new URL(param)); return 1; } catch (MalformedURLException e) { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, params.getParameter(-1), param); } }
public int parseArguments(Parameters parameters) throws CmdLineException { for (int i=0; i<parameters.size(); i++) setter.addValue(parameters.getParameter(i)); return parameters.size(); }
@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)); }
@Override public int parseArguments (org.kohsuke.args4j.spi.Parameters params) throws CmdLineException { String className = params.getParameter(0).trim(); if (!className.isEmpty()) { try { Class runClass = Class.forName(className); FieldSetter fs = setter.asFieldSetter(); fs.addValue(runClass); } catch (ClassNotFoundException ex) { throw new CmdLineException(owner, ex); } } return 1; } }
@Override public int parseArguments(Parameters params) throws CmdLineException { final Jenkins j = Jenkins.get(); final String src = params.getParameter(0); T s = j.getItemByFullName(src, type()); if (s == null) { final Authentication who = Jenkins.getAuthentication(); try (ACLContext acl = ACL.as(ACL.SYSTEM)) { Item actual = j.getItemByFullName(src); if (actual == null) { LOGGER.log(Level.FINE, "really no item exists named {0}", src); } else { LOGGER.log(Level.WARNING, "running as {0} could not find {1} of {2}", new Object[] {who.getPrincipal(), actual, type()}); } } T nearest = Items.findNearest(type(), src, j); if (nearest != null) { throw new IllegalArgumentException("No such job '" + src + "'; perhaps you meant '" + nearest.getFullName() + "'?"); } else { throw new IllegalArgumentException("No such job '" + src + "'"); } } setter.addValue(s); return 1; }