org.graylog2.bootstrap.Main Maven / Gradle / Ivy
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog2.bootstrap;
import com.github.rvesse.airline.Cli;
import com.github.rvesse.airline.builder.CliBuilder;
import com.google.common.collect.ImmutableSet;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.graylog2.bootstrap.commands.CliCommandHelp;
import org.graylog2.bootstrap.commands.ShowVersion;
import java.security.Security;
import java.util.ServiceLoader;
public class Main {
public static void main(String[] args) {
final CliBuilder builder = Cli.builder("graylog")
.withDescription("Open source, centralized log management")
.withDefaultCommand(CliCommandHelp.class)
.withCommands(ImmutableSet.of(
ShowVersion.class,
CliCommandHelp.class));
// add rest from classpath
final ServiceLoader commandsProviders = ServiceLoader.load(CliCommandsProvider.class);
for (CliCommandsProvider provider : commandsProviders) {
provider.addTopLevelCommandsOrGroups(builder);
}
final Cli cli = builder.build();
final Runnable command = cli.parse(args);
// Explicitly register Bouncy Castle as security provider.
// This allows us to use more key formats than with JCE
Security.addProvider(new BouncyCastleProvider());
command.run();
}
}