use of ai.grakn.graql.shell.GraknSessionProvider in project grakn by graknlabs.
the class Graql method main.
/**
* Invocation from bash script 'graql'
*
* @param args
*/
public static void main(String[] args) throws IOException, InterruptedException {
GraknSessionProvider sessionProvider = new GraknSessionProvider(GraknConfig.create());
GraqlShellOptionsFactory graqlShellOptionsFactory = GraqlShellOptions::create;
new Graql(sessionProvider, graqlShellOptionsFactory).run(args);
}
use of ai.grakn.graql.shell.GraknSessionProvider 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);
}
Aggregations