Created
March 13, 2019 19:07
-
-
Save SevereOverfl0w/c4c8876f20d6ce1772a77e2cc216d814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:import [org.cactoos.io InputOf TeeInput] | |
[org.buildobjects.process ProcBuilder] | |
[org.zeroturnaround.exec ProcessExecutor] | |
[org.apache.commons.io.input ReaderInputStream] | |
[org.apache.commons.io.output WriterOutputStream])) | |
(defn reload | |
[] | |
(require 'user :reload)) | |
(defn *in*-stream | |
[] | |
(new org.cactoos.io.InputStreamOf *in*)) | |
(defn *out*-stream | |
[] | |
(new org.cactoos.io.OutputStreamTo *out*)) | |
(defn *in*-stream-alt | |
[] | |
(new ReaderInputStream *in* "UTF-8")) | |
(defn *out*-stream-alt | |
[] | |
(new WriterOutputStream *out* "UTF-8")) | |
(defn vim | |
[] | |
(-> (new ProcessExecutor) | |
(.command (into-array String ["nvim"])) | |
(.redirectOutput (*out*-stream-alt)) | |
(.redirectInput (*in*-stream-alt)) | |
(.execute))) | |
(defn foo | |
[] | |
(with-open [out (*out*-stream-alt) | |
in (*in*-stream-alt)] | |
(-> (new ProcBuilder "/bin/sh" (into-array String ["-c" "sleep 1 && echo 'HI' && read FOO"])) | |
(.withOutputStream out) | |
(.withInputStream in) | |
(.run)))) | |
(defn foo2 | |
[] | |
(let [in (*in*-stream-alt)] | |
(-> (new ProcessExecutor) | |
(.command (into-array String ["/bin/sh" "-c" "sleep 1 && echo 'HI'"])) | |
(.redirectOutput (*out*-stream-alt)) | |
(.redirectInput in) | |
(.execute)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment