Package org.kohsuke.args4j

Examples of org.kohsuke.args4j.CmdLineException


          phaseName = phaseName.toUpperCase().replace("-", "_");
          Phase phase;
          try {
            phase = Phase.valueOf(phaseName);
          } catch (IllegalArgumentException iax) {
            throw new CmdLineException(parser, "illegal phase name in --dot flag: " + phaseName);
          }
          result.add(phase);
        }
      }
    }
View Full Code Here


    this.err = err;
  }

  public void validate() throws CmdLineException {
    if (cp == null && entryList.isEmpty()) {
      throw new CmdLineException("You must supply either the -cp flag, " +
          "or the argument \"classes and packages to analyze\".");
    }
    cp = (cp != null ? cp : System.getProperty("java.class.path", "."));
    if (entryList.isEmpty()) {
      entryList.add(".");
    }
    try {
      format = ReportFormat.valueOf(printer);
    } catch (IllegalArgumentException e) {
      throw new CmdLineException("Don't understand '-print' option '" + printer + "'");
    }
  }
View Full Code Here

      parser.parseArgument(args);
    } catch (CmdLineException e) {
      System.err.println(e.getMessage() + "\n");
      parser.setUsageWidth(120);
      parser.printUsage(System.err);
      throw new CmdLineException("Exiting...");
    }
  }
View Full Code Here

        if (item==null) {
            List<String> names = new ArrayList<String>();
            for (Computer c : h.getComputers())
                if (c.getName().length()>0)
                    names.add(c.getName());
            throw new CmdLineException(null,Messages.Computer_NoSuchSlaveExists(name,EditDistance.findNearest(name,names)));
        }
        return item;
    }
View Full Code Here

        @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;
        }
View Full Code Here

    public RunT getBuildForCLI(@Argument(required=true,metaVar="BUILD#",usage="Build number") String id) throws CmdLineException {
        try {
            int n = Integer.parseInt(id);
            RunT r = getBuildByNumber(n);
            if (r==null)
                throw new CmdLineException(null, "No such build '#"+n+"' exists");
            return r;
        } catch (NumberFormatException e) {
            throw new CmdLineException(null, id+ "is not a number");
        }
    }
View Full Code Here

    /**
     * Loads the script from the argument.
     */
    private String loadScript() throws CmdLineException, IOException, InterruptedException {
        if(script==null)
            throw new CmdLineException(null, "No script is specified");
        if (script.equals("="))
            return IOUtils.toString(stdin);

        return checkChannel().call(new ScriptLoader(script));
    }
View Full Code Here

            CLICommand c = CLICommand.getCurrent();
            if (c==null)    throw new IllegalStateException("Not executing a CLI command");
            String[] envs = c.checkChannel().call(new GetCharacteristicEnvironmentVariables());

            if (envs[0]==null || envs[1]==null)
                throw new CmdLineException("This CLI command works only when invoked from inside a build");

            Job j = Jenkins.getInstance().getItemByFullName(envs[0],Job.class);
            if (j==null)    throw new CmdLineException("No such job: "+envs[0]);

            try {
                Run r = j.getBuildByNumber(Integer.parseInt(envs[1]));
                if (r==null)    throw new CmdLineException("No such build #"+envs[1]+" in "+envs[0]);
                return r;
            } catch (NumberFormatException e) {
                throw new CmdLineException("Invalid build number: "+envs[1]);
            }
        } catch (IOException e) {
            throw new CmdLineException("Failed to identify the build being executed",e);
        } catch (InterruptedException e) {
            throw new CmdLineException("Failed to identify the build being executed",e);
        }
    }
View Full Code Here

    @CLIResolver
    public static AbstractItem resolveForCLI(
            @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
        AbstractItem item = Jenkins.getInstance().getItemByFullName(name, AbstractItem.class);
        if (item==null)
            throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
        return item;
    }
View Full Code Here

        TopLevelItem s = h.getItem(src);
        if (s==null) {
            AbstractProject nearest = AbstractProject.findNearest(src);
            if (nearest!=null)
                throw new CmdLineException(owner, "No such job '"+src+"' perhaps you meant '"+ nearest.getFullName() +"'?");
            else
                throw new CmdLineException(owner, "No such job '"+src+"'");
        }
           
        setter.addValue(s);
        return 1;
    }
View Full Code Here

TOP

Related Classes of org.kohsuke.args4j.CmdLineException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.