Search in sources :

Example 81 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project hudson-2.x by hudson.

the class Launcher method main.

public static void main(String... args) throws Exception {
    Launcher launcher = new Launcher();
    CmdLineParser parser = new CmdLineParser(launcher);
    try {
        parser.parseArgument(args);
        launcher.run();
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println("java -jar slave.jar [options...]");
        parser.printUsage(System.err);
        System.err.println();
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 82 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project gitblit by gitblit.

the class FederationClient method main.

public static void main(String[] args) {
    Params params = new Params();
    CmdLineParser parser = new CmdLineParser(params);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException t) {
        usage(parser, t);
    }
    System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
    // command-line specified base folder
    File baseFolder = new File(System.getProperty("user.dir"));
    if (!StringUtils.isEmpty(params.baseFolder)) {
        baseFolder = new File(params.baseFolder);
    }
    File regFile = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.registrationsFile);
    FileSettings settings = new FileSettings(regFile.getAbsolutePath());
    List<FederationModel> registrations = new ArrayList<FederationModel>();
    if (StringUtils.isEmpty(params.url)) {
        registrations.addAll(FederationUtils.getFederationRegistrations(settings));
    } else {
        if (StringUtils.isEmpty(params.token)) {
            System.out.println("Must specify --token parameter!");
            System.exit(0);
        }
        FederationModel model = new FederationModel("Gitblit");
        model.url = params.url;
        model.token = params.token;
        model.mirror = params.mirror;
        model.bare = params.bare;
        model.folder = "";
        registrations.add(model);
    }
    if (registrations.size() == 0) {
        System.out.println("No Federation Registrations!  Nothing to do.");
        System.exit(0);
    }
    // command-line specified repositories folder
    if (!StringUtils.isEmpty(params.repositoriesFolder)) {
        settings.overrideSetting(Keys.git.repositoriesFolder, new File(params.repositoriesFolder).getAbsolutePath());
    }
    // configure the Gitblit singleton for minimal, non-server operation
    XssFilter xssFilter = new AllowXssFilter();
    RuntimeManager runtime = new RuntimeManager(settings, xssFilter, baseFolder).start();
    NoopNotificationManager notifications = new NoopNotificationManager().start();
    UserManager users = new UserManager(runtime, null).start();
    RepositoryManager repositories = new RepositoryManager(runtime, null, users).start();
    FederationManager federation = new FederationManager(runtime, notifications, repositories).start();
    IGitblit gitblit = new GitblitManager(null, null, runtime, null, notifications, users, null, repositories, null, federation, null);
    FederationPullService puller = new FederationPullService(gitblit, federation.getFederationRegistrations()) {

        @Override
        public void reschedule(FederationModel registration) {
        // NOOP
        }
    };
    puller.run();
    System.out.println("Finished.");
    System.exit(0);
}
Also used : FederationModel(com.gitblit.models.FederationModel) CmdLineParser(org.kohsuke.args4j.CmdLineParser) GitblitManager(com.gitblit.manager.GitblitManager) FederationManager(com.gitblit.manager.FederationManager) ArrayList(java.util.ArrayList) RuntimeManager(com.gitblit.manager.RuntimeManager) IGitblit(com.gitblit.manager.IGitblit) FederationPullService(com.gitblit.service.FederationPullService) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) RepositoryManager(com.gitblit.manager.RepositoryManager) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 83 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project gitblit by gitblit.

the class MigrateTickets method main.

public static void main(String... args) {
    MigrateTickets migrate = new MigrateTickets();
    // filter out the baseFolder parameter
    List<String> filtered = new ArrayList<String>();
    String folder = "data";
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--baseFolder")) {
            if (i + 1 == args.length) {
                System.out.println("Invalid --baseFolder parameter!");
                System.exit(-1);
            } else if (!".".equals(args[i + 1])) {
                folder = args[i + 1];
            }
            i = i + 1;
        } else {
            filtered.add(arg);
        }
    }
    Params.baseFolder = folder;
    Params params = new Params();
    CmdLineParser parser = new CmdLineParser(params);
    try {
        parser.parseArgument(filtered);
        if (params.help) {
            migrate.usage(parser, null);
            return;
        }
    } catch (CmdLineException t) {
        migrate.usage(parser, t);
        return;
    }
    // load the settings
    FileSettings settings = params.FILESETTINGS;
    if (!StringUtils.isEmpty(params.settingsfile)) {
        if (new File(params.settingsfile).exists()) {
            settings = new FileSettings(params.settingsfile);
        }
    }
    // migrate tickets
    migrate.migrate(new File(Params.baseFolder), settings, params.outputServiceName);
    System.exit(0);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ArrayList(java.util.ArrayList) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 84 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project gitblit by gitblit.

the class ReindexTickets method main.

public static void main(String... args) {
    ReindexTickets reindex = new ReindexTickets();
    // filter out the baseFolder parameter
    List<String> filtered = new ArrayList<String>();
    String folder = "data";
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--baseFolder")) {
            if (i + 1 == args.length) {
                System.out.println("Invalid --baseFolder parameter!");
                System.exit(-1);
            } else if (!".".equals(args[i + 1])) {
                folder = args[i + 1];
            }
            i = i + 1;
        } else {
            filtered.add(arg);
        }
    }
    Params.baseFolder = folder;
    Params params = new Params();
    CmdLineParser parser = new CmdLineParser(params);
    try {
        parser.parseArgument(filtered);
        if (params.help) {
            reindex.usage(parser, null);
            return;
        }
    } catch (CmdLineException t) {
        reindex.usage(parser, t);
        return;
    }
    // load the settings
    FileSettings settings = params.FILESETTINGS;
    if (!StringUtils.isEmpty(params.settingsfile)) {
        if (new File(params.settingsfile).exists()) {
            settings = new FileSettings(params.settingsfile);
        }
    }
    // reindex tickets
    reindex.reindex(new File(Params.baseFolder), settings);
    System.exit(0);
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ArrayList(java.util.ArrayList) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 85 with CmdLineParser

use of org.kohsuke.args4j.CmdLineParser in project buck by facebook.

the class StringSetOptionHandlerTest method testOptionSpecifiedWithEmptyElements.

@Test
public void testOptionSpecifiedWithEmptyElements() throws CmdLineException {
    TestBean bean = new TestBean();
    CmdLineParser parser = new CmdLineParser(bean);
    parser.parseArgument("--option1", "", "a");
    assertEquals(ImmutableSet.of("", "a"), bean.getOption1());
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) Test(org.junit.Test)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)119 CmdLineException (org.kohsuke.args4j.CmdLineException)80 File (java.io.File)16 Test (org.junit.Test)14 IOException (java.io.IOException)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 ArrayList (java.util.ArrayList)9 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 PrintStream (java.io.PrintStream)6 FileOutputStream (java.io.FileOutputStream)4 List (java.util.List)4 FeatureExtractors (io.anserini.ltr.feature.FeatureExtractors)3 Qrels (io.anserini.util.Qrels)3 Directory (org.apache.lucene.store.Directory)3 FSDirectory (org.apache.lucene.store.FSDirectory)3 ConsoleReporter (com.codahale.metrics.ConsoleReporter)2 MetricRegistry (com.codahale.metrics.MetricRegistry)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2