use of ai.grakn.graql.shell.GraqlShellOptions in project grakn by graknlabs.
the class GraqlShellIT method runShell.
private ShellResponse runShell(String input, String... args) throws Exception {
args = addKeyspaceAndUriParams(args);
InputStream in = new ByteArrayInputStream(input.getBytes());
OutputStream bout = new ByteArrayOutputStream();
OutputStream berr = new ByteArrayOutputStream();
OutputStream tout = bout;
OutputStream terr = berr;
if (showStdOutAndErr) {
// Intercept stdout and stderr, but make sure it is still printed using the TeeOutputStream
tout = new TeeOutputStream(bout, System.out);
terr = new TeeOutputStream(berr, System.err);
}
PrintStream out = new PrintStream(tout);
PrintStream err = new PrintStream(terr);
Boolean success = null;
GraknConfig config = GraknConfig.create();
try {
System.setIn(in);
GraqlShellOptions options = GraqlShellOptions.create(args);
success = GraqlConsole.start(options, new GraknSessionProvider(config), historyFile, out, err);
} catch (Exception e) {
e.printStackTrace();
err.flush();
fail(berr.toString());
} finally {
resetIO();
}
out.flush();
err.flush();
assertNotNull(success);
return ShellResponse.of(bout.toString(), berr.toString(), success);
}
use of ai.grakn.graql.shell.GraqlShellOptions in project grakn by graknlabs.
the class Graql method run.
public void run(String[] args) throws IOException, InterruptedException {
String context = args.length > 0 ? args[0] : "";
switch(context) {
case "console":
GraqlShellOptions options;
try {
options = graqlShellOptionsFactory.createGraqlShellOptions(valuesFrom(args, 1));
} catch (ParseException e) {
System.err.println(e.getMessage());
return;
}
GraqlConsole.start(options, sessionProvider, HISTORY_FILENAME, System.out, System.err);
break;
case "migrate":
migrate(valuesFrom(args, 1));
break;
case "version":
version();
break;
default:
help();
}
}
Aggregations