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();
}
}
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);
}
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);
}
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);
}
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());
}
Aggregations