private String openTextEditor ( ) throws IOException , InterruptedException { String editor = Optional . ofNullable ( System . getenv ( ) . get ( "EDITOR" ) ) . orElse ( EDITOR_DEFAULT ) ; File tempFile = new File ( StandardSystemProperty . JAVA_IO_TMPDIR . value ( ) + EDITOR_FILE ) ; tempFile . createNewFile ( ) ; // Run the editor, pipe input into and out of tty so we can provide the input/output to the editor via Graql ProcessBuilder builder = new ProcessBuilder ( "/bin/bash" , "-c" , editor + " </dev/tty >/dev/tty " + tempFile . getAbsolutePath ( ) ) ; builder . start ( ) . waitFor ( ) ; return String . join ( "\n" , Files . readAllLines ( tempFile . toPath ( ) ) ) ; }
Open the user s preferred editor to write a query