Search in sources :

Example 11 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class GeogigCLI method main.

/**
     * Entry point for the command line interface.
     * 
     * @param args
     */
public static void main(String[] args) {
    Logging.tryConfigureLogging();
    ConsoleReader consoleReader;
    try {
        consoleReader = new ConsoleReader(System.in, System.out);
        // needed for CTRL+C not to let the console broken
        consoleReader.getTerminal().setEchoEnabled(true);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
    final GeogigCLI cli = new GeogigCLI(consoleReader);
    addShutdownHook(cli);
    int exitCode = cli.execute(args);
    try {
        cli.close();
    } finally {
        try {
            consoleReader.getTerminal().restore();
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
            exitCode = -1;
        }
        consoleReader.shutdown();
    }
    if (exitCode != 0 || cli.isExitOnFinish()) {
        System.exit(exitCode);
    }
}
Also used : ConsoleReader(jline.console.ConsoleReader) ParameterException(com.beust.jcommander.ParameterException) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) IOException(java.io.IOException) CannotRunGeogigOperationException(org.locationtech.geogig.api.hooks.CannotRunGeogigOperationException)

Example 12 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class ShpImportTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    setUpGeogig(cli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) Before(org.junit.Before)

Example 13 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class PGDescribeTest method testDescribeException.

@Test
public void testDescribeException() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
    setUpGeogig(mockCli);
    when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
    PGDescribe describeCommand = new PGDescribe();
    describeCommand.table = "table1";
    describeCommand.dataStoreFactory = TestHelper.createTestFactory();
    exception.expect(MockitoException.class);
    describeCommand.run(mockCli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 14 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class PGExportTest method setUpInternal.

@Override
public void setUpInternal() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    cli.setGeogig(geogig);
    // Add points
    insertAndAdd(points1);
    insertAndAdd(points2);
    insertAndAdd(points3);
    geogig.command(CommitOp.class).call();
    // Add lines
    insertAndAdd(lines1);
    insertAndAdd(lines2);
    insertAndAdd(lines3);
    geogig.command(CommitOp.class).call();
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp)

Example 15 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class PGImportTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    setUpGeogig(cli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) Before(org.junit.Before)

Aggregations

ConsoleReader (jline.console.ConsoleReader)95 UnsupportedTerminal (jline.UnsupportedTerminal)44 GeogigCLI (org.locationtech.geogig.cli.GeogigCLI)42 GeoGIG (org.locationtech.geogig.api.GeoGIG)22 Before (org.junit.Before)19 IOException (java.io.IOException)17 Test (org.junit.Test)17 File (java.io.File)12 MockitoException (org.mockito.exceptions.base.MockitoException)12 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)11 ObjectId (org.locationtech.geogig.api.ObjectId)9 TestPlatform (org.locationtech.geogig.api.TestPlatform)8 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)8 Ref (org.locationtech.geogig.api.Ref)7 CLITestContextBuilder (org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder)7 Ansi (org.fusesource.jansi.Ansi)6 NodeRef (org.locationtech.geogig.api.NodeRef)6 RevCommit (org.locationtech.geogig.api.RevCommit)6 FileInputStream (java.io.FileInputStream)4 RevObject (org.locationtech.geogig.api.RevObject)4