Search in sources :

Example 1 with Options

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();
    }
}
Also used : Closer(com.google.common.io.Closer) CommonOptions(org.apache.jackrabbit.oak.run.cli.CommonOptions) Options(org.apache.jackrabbit.oak.run.cli.Options) NodeStoreFixture(org.apache.jackrabbit.oak.run.cli.NodeStoreFixture) OptionParser(joptsimple.OptionParser) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Example 2 with Options

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);
}
Also used : OptionSpec(joptsimple.OptionSpec) Options(org.apache.jackrabbit.oak.run.cli.Options) IO(org.codehaus.groovy.tools.shell.IO) NodeStoreFixture(org.apache.jackrabbit.oak.run.cli.NodeStoreFixture) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Aggregations

OptionParser (joptsimple.OptionParser)2 NodeStoreFixture (org.apache.jackrabbit.oak.run.cli.NodeStoreFixture)2 Options (org.apache.jackrabbit.oak.run.cli.Options)2 Closer (com.google.common.io.Closer)1 OptionSet (joptsimple.OptionSet)1 OptionSpec (joptsimple.OptionSpec)1 CommonOptions (org.apache.jackrabbit.oak.run.cli.CommonOptions)1 StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)1 IO (org.codehaus.groovy.tools.shell.IO)1