use of org.apache.jackrabbit.oak.run.cli.Options in project jackrabbit-oak by apache.
the class IndexCommand method execute.
@Override
public void execute(String... args) throws Exception {
OptionParser parser = new OptionParser();
opts = new Options();
opts.setCommandName(NAME);
opts.setSummary(summary);
opts.setConnectionString(CommonOptions.DEFAULT_CONNECTION_STRING);
opts.registerOptionsFactory(IndexOptions.FACTORY);
opts.parseAndConfigure(parser, args);
IndexOptions indexOpts = opts.getOptionBean(IndexOptions.class);
//Clean up before setting up NodeStore as the temp
//directory might be used by NodeStore for cache stuff like persistentCache
setupDirectories(indexOpts);
NodeStoreFixture fixture = NodeStoreFixtureProvider.create(opts);
try (Closer closer = Closer.create()) {
closer.register(fixture);
StatisticsProvider statisticsProvider = WhiteboardUtils.getService(fixture.getWhiteboard(), StatisticsProvider.class);
execute(fixture.getStore(), fixture.getBlobStore(), statisticsProvider, indexOpts, closer);
tellReportPaths();
}
}
use of org.apache.jackrabbit.oak.run.cli.Options in project jackrabbit-oak by apache.
the class Console method main.
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSpec quiet = parser.accepts("quiet", "be less chatty");
OptionSpec shell = parser.accepts("shell", "run the shell after executing files");
Options opts = new Options();
OptionSet options = opts.parseAndConfigure(parser, args);
NodeStoreFixture fixture = NodeStoreFixtureProvider.create(opts);
List<String> nonOptions = opts.getCommonOpts().getNonOptions();
List<String> scriptArgs = nonOptions.size() > 1 ? nonOptions.subList(1, nonOptions.size()) : Collections.emptyList();
IO io = new IO();
if (options.has(quiet)) {
io.setVerbosity(IO.Verbosity.QUIET);
}
if (!opts.getCommonOpts().isReadWrite()) {
io.out.println("Repository connected in read-only mode. Use '--read-write' for write operations");
}
GroovyConsole console = new GroovyConsole(ConsoleSession.create(fixture.getStore(), fixture.getWhiteboard()), new IO(), fixture);
int code = 0;
if (!scriptArgs.isEmpty()) {
code = console.execute(scriptArgs);
}
if (scriptArgs.isEmpty() || options.has(shell)) {
code = console.run();
}
System.exit(code);
}
Aggregations