use of jline.UnsupportedTerminal in project GeoGig by boundlessgeo.
the class GeoJsonExportTest 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();
}
use of jline.UnsupportedTerminal in project GeoGig by boundlessgeo.
the class GeoJsonImportTest method setUp.
@Before
public void setUp() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
cli = new GeogigCLI(consoleReader);
setUpGeogig(cli);
}
use of jline.UnsupportedTerminal in project GeoGig by boundlessgeo.
the class OracleDescribeTest 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"));
OracleDescribe describeCommand = new OracleDescribe();
describeCommand.table = "table1";
describeCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
describeCommand.run(mockCli);
}
use of jline.UnsupportedTerminal in project GeoGig by boundlessgeo.
the class ConsoleResourceResource method processRequest.
private JsonObject processRequest(JsonObject json, final GeoGIG geogig) {
JsonObject response;
final String command = json.get("method").getAsString();
final String queryId = json.get("id").getAsString();
// not used, we're getting the whole command and args in the "method" object
// JsonArray paramsArray = json.get("params").getAsJsonArray();
InputStream in = new ByteArrayInputStream(new byte[0]);
// dumps output to a temp file if > threshold
FileBackedOutputStream out = new FileBackedOutputStream(4096);
try {
// pass it a BufferedOutputStream 'cause it doesn't buffer the internal FileOutputStream
ConsoleReader console = new ConsoleReader(in, new BufferedOutputStream(out), new UnsupportedTerminal());
Platform platform = geogig.getPlatform();
GeogigCLI geogigCLI = new GeogigCLI(geogig, console);
geogigCLI.setPlatform(platform);
geogigCLI.disableProgressListener();
String[] args = ArgumentTokenizer.tokenize(command);
final int exitCode = geogigCLI.execute(args);
response = new JsonObject();
response.addProperty("id", queryId);
final int charCountLimit = getOutputLimit(geogig.getContext());
final StringBuilder output = getLimitedOutput(out, charCountLimit);
if (exitCode == 0) {
response.addProperty("result", output.toString());
response.addProperty("error", (String) null);
} else {
Exception exception = geogigCLI.exception;
JsonObject error = buildError(exitCode, output, exception);
response.add("error", error);
}
return response;
} catch (IOException e) {
throw Throwables.propagate(e);
} finally {
// delete temp file
try {
out.reset();
} catch (IOException ignore) {
ignore.printStackTrace();
}
}
}
use of jline.UnsupportedTerminal in project GeoGig by boundlessgeo.
the class GeogigConsole method run.
private void run(final InputStream in, final OutputStream out) throws IOException {
final Terminal terminal;
if (interactive) {
terminal = null;
/* let jline select an appropriate one */
} else {
// no colors in output
terminal = new UnsupportedTerminal();
}
ConsoleReader consoleReader = new ConsoleReader(in, out, terminal);
consoleReader.setAutoprintThreshold(20);
consoleReader.setPaginationEnabled(interactive);
consoleReader.setHistoryEnabled(interactive);
// needed for CTRL+C not to let the console broken
consoleReader.getTerminal().setEchoEnabled(interactive);
final GeogigCLI cli = new GeogigCLI(consoleReader);
if (interactive) {
addCommandCompleter(consoleReader, cli);
} else {
// no progress percent in output
cli.disableProgressListener();
}
GeogigCLI.addShutdownHook(cli);
setPrompt(cli);
cli.close();
try {
runInternal(cli);
} finally {
try {
cli.close();
} finally {
try {
if (terminal != null) {
terminal.restore();
}
consoleReader.shutdown();
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
}
}
Aggregations