Examples of CmdLineParser


Examples of org.kohsuke.args4j.CmdLineParser

    /**
     * @param args - URL to fetch
     */
    public static void main(String[] args) {
        FetchAndParseToolOptions options = new FetchAndParseToolOptions();
        CmdLineParser cmdParser = new CmdLineParser(options);
       
        try {
            cmdParser.parseArgument(args);
        } catch(CmdLineException e) {
            System.err.println(e.getMessage());
            printUsageAndExit(cmdParser);
        }

View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

public class BuildCache {
    public static final String BUILD_CACHE_FAILED_MESSAGE = "Granule cache build failed. Error count: {0}";

  public static void main(String[] args) {
        BuildCacheOptions options = new BuildCacheOptions();
        CmdLineParser parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            System.err.println("java -jar granule.jar [options...] arguments...");
            parser.printUsage(System.err);
            return;
        }
        String rootdir = options.getRootpath();
        if (rootdir == null) rootdir = ".";
        File f = new File(rootdir);
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

    @SuppressWarnings("rawtypes")
    public static void main(String[] args) throws IOException {
       
        DemoWebMiningOptions options = new DemoWebMiningOptions();
        CmdLineParser parser = new CmdLineParser(options);

        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            printUsageAndExit(parser);
        }
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser


  @SuppressWarnings("rawtypes")
    public static void main(String[] args) {
    AnalyzeMboxOptions options = new AnalyzeMboxOptions();
        CmdLineParser parser = new CmdLineParser(options);
       
        try {
            parser.parseArgument(args);
        } catch(CmdLineException e) {
            System.err.println(e.getMessage());
            printUsageAndExit(parser);
        }
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

    }
    report.writeHtml(out);
  }

  private void parseArgs(String[] args) throws CmdLineException {
    CmdLineParser parser = new CmdLineParser(this);
    try {
      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

Examples of org.kohsuke.args4j.CmdLineParser

  protected void configure() {
    // For printing errors to the caller
    bind(PrintStream.class).annotatedWith(Output.class).toInstance(System.out);
    bind(PrintStream.class).annotatedWith(Error.class).toInstance(System.err);
    CommandLineConfig config = new CommandLineConfig(out, err);
    CmdLineParser parser = new CmdLineParser(config);
    // We actually do this work in configure, since we want to bind the parsed command line
    // options at this time
    try {
      parser.parseArgument(args);
      config.validate();
      bind(ClassPath.class).toInstance(new ClassPathFactory().createFromPath(config.cp));
      bind(ReportFormat.class).toInstance(config.format);     
    } catch (CmdLineException e) {
      err.println(e.getMessage() + "\n");
      parser.setUsageWidth(120);
      parser.printUsage(err);
      err.println("Exiting...");
    }
    bind(CommandLineConfig.class).toInstance(config);
    bind(ReportOptions.class).toInstance(new ReportOptions(
        config.cyclomaticMultiplier, config.globalMultiplier, config.constructorMultiplier,
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

        this.stdin = new BufferedInputStream(stdin);
        this.stdout = stdout;
        this.stderr = stderr;
        this.locale = locale;
        registerOptionHandlers();
        CmdLineParser p = new CmdLineParser(this);

        // add options from the authenticator
        SecurityContext sc = SecurityContextHolder.getContext();
        Authentication old = sc.getAuthentication();

        CliAuthenticator authenticator = Jenkins.getInstance().getSecurityRealm().createCliAuthenticator(this);
        new ClassParser().parse(authenticator,p);

        try {
            p.parseArgument(args.toArray(new String[args.size()]));
            Authentication auth = authenticator.authenticate();
            if (auth==Jenkins.ANONYMOUS)
                auth = loadStoredAuthentication();
            sc.setAuthentication(auth); // run the CLI with the right credential
            if (!(this instanceof LoginCommand || this instanceof HelpCommand))
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

                            this.stdout = stdout;
                            this.stderr = stderr;
                            this.locale = locale;

                            registerOptionHandlers();
                            CmdLineParser parser = new CmdLineParser(null);
                            try {
                                SecurityContext sc = SecurityContextHolder.getContext();
                                Authentication old = sc.getAuthentication();
                                try {
                                    //  build up the call sequence
                                    Stack<Method> chains = new Stack<Method>();
                                    Method method = m;
                                    while (true) {
                                        chains.push(method);
                                        if (Modifier.isStatic(method.getModifiers()))
                                            break; // the chain is complete.

                                        // the method in question is an instance method, so we need to resolve the instance by using another resolver
                                        Class<?> type = method.getDeclaringClass();
                                        method = findResolver(type);
                                        if (method==null) {
                                            stderr.println("Unable to find the resolver method annotated with @CLIResolver for "+type);
                                            return 1;
                                        }
                                    }

                                    List<MethodBinder> binders = new ArrayList<MethodBinder>();

                                    while (!chains.isEmpty())
                                        binders.add(new MethodBinder(chains.pop(),this,parser));

                                    // authentication
                                    CliAuthenticator authenticator = Jenkins.getInstance().getSecurityRealm().createCliAuthenticator(this);
                                    new ClassParser().parse(authenticator,parser);

                                    // fill up all the binders
                                    parser.parseArgument(args);

                                    Authentication auth = authenticator.authenticate();
                                    if (auth== Jenkins.ANONYMOUS)
                                        auth = loadStoredAuthentication();
                                    sc.setAuthentication(auth); // run the CLI with the right credential
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

    }

    @Override
    public int run(String[] args) throws Exception {
        options = new Options();
        CmdLineParser parser = new CmdLineParser(options);
        String s = options.toString();

        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            parser.printUsage(System.err);
            return -1;
        }

        this.userIndex = HashBiMap.create();
        this.itemIndex = HashBiMap.create();
View Full Code Here

Examples of org.kohsuke.args4j.CmdLineParser

    private static Options options;

    @Override
    public int run(String[] args) throws Exception {
        options = new Options();
        CmdLineParser parser = new CmdLineParser(options);
        String s = options.toString();

        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            parser.printUsage(System.err);
            return -1;
        }


        cleanOutputDirs(options);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.