diff options
-rw-r--r-- | clpmfile.lock | 142 | ||||
-rw-r--r-- | oneliners.cli.asd | 15 | ||||
-rw-r--r-- | src/main.lisp | 29 |
3 files changed, 156 insertions, 30 deletions
diff --git a/clpmfile.lock b/clpmfile.lock index a323631..c490373 100644 --- a/clpmfile.lock +++ b/clpmfile.lock @@ -31,18 +31,46 @@ ("babel" :version "2020-09-25" :source "quicklisp" :systems ("babel")) ("bordeaux-threads" :version "2020-06-10" :source "quicklisp" :systems ("bordeaux-threads")) -("cffi" :version "2021-04-11" :source "quicklisp" :systems ("cffi")) -("cl-readline" :version "2021-10-21" :source "quicklisp" :systems - ("cl-readline")) -("dissect" :version "2021-05-31" :source "quicklisp" :systems ("dissect")) +("cffi" :version "2021-04-11" :source "quicklisp" :systems + ("cffi" "cffi-grovel" "cffi-toolchain")) +("chipz" :version "2021-08-07" :source "quicklisp" :systems ("chipz")) +("chunga" :version "2020-04-27" :source "quicklisp" :systems ("chunga")) +("cl+ssl" :version "2021-12-30" :source "quicklisp" :systems ("cl+ssl")) +("cl-base64" :version "2020-10-16" :source "quicklisp" :systems ("cl-base64")) +("cl-cookie" :version "2019-10-07" :source "quicklisp" :systems ("cl-cookie")) +("cl-ppcre" :version "2019-05-21" :source "quicklisp" :systems ("cl-ppcre")) +("cl-utilities" :version "2010-10-07" :source "quicklisp" :systems + ("cl-utilities")) +("dexador" :version "2021-12-09" :source "quicklisp" :systems ("dexador")) +("fast-http" :version "2019-10-07" :source "quicklisp" :systems ("fast-http")) +("fast-io" :version "2020-09-25" :source "quicklisp" :systems ("fast-io")) +("flexi-streams" :version "2021-08-07" :source "quicklisp" :systems + ("flexi-streams")) +("local-time" :version "2021-01-24" :source "quicklisp" :systems ("local-time")) ("oneliners.cli.asd" :version :newest :source :implicit-file :systems - ("oneliners.cli" "oneliners.cli/tests")) -("rove" :version "2021-12-09" :source "quicklisp" :systems ("rove")) + ("oneliners.cli")) +("osicat" :version "2021-12-09" :source "quicklisp" :systems ("osicat")) +("proc-parse" :version "2019-08-13" :source "quicklisp" :systems ("proc-parse")) +("quri" :version "2021-06-30" :source "quicklisp" :systems ("quri")) +("smart-buffer" :version "2021-10-21" :source "quicklisp" :systems + ("smart-buffer")) +("split-sequence" :version "2021-05-31" :source "quicklisp" :systems + ("split-sequence")) +("static-vectors" :version "2021-06-30" :source "quicklisp" :systems + ("static-vectors")) +("trivial-clipboard" :version "2021-02-28" :source "quicklisp" :systems + ("trivial-clipboard")) ("trivial-features" :version "2021-12-09" :source "quicklisp" :systems ("trivial-features")) +("trivial-garbage" :version "2021-12-30" :source "quicklisp" :systems + ("trivial-garbage")) ("trivial-gray-streams" :version "2021-01-24" :source "quicklisp" :systems ("trivial-gray-streams")) +("trivial-mimes" :version "2020-07-15" :source "quicklisp" :systems + ("trivial-mimes")) ("unix-opts" :version "2021-01-24" :source "quicklisp" :systems ("unix-opts")) +("usocket" :version "2019-12-27" :source "quicklisp" :systems ("usocket")) +("xsubseq" :version "2017-08-30" :source "quicklisp" :systems ("xsubseq")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -50,32 +78,110 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; :reverse-dependencies -("alexandria" ((:system :name "cl-readline") (:system :name "alexandria")) +("alexandria" ((:system :name "static-vectors") (:system :name "alexandria")) + ((:system :name "quri") (:system :name "alexandria")) + ((:system :name "proc-parse") (:system :name "alexandria")) + ((:system :name "osicat") (:system :name "alexandria")) + ((:system :name "fast-io") (:system :name "alexandria")) + ((:system :name "fast-http") (:system :name "alexandria")) + ((:system :name "dexador") (:system :name "alexandria")) + ((:system :name "cl-cookie") (:system :name "alexandria")) + ((:system :name "cl+ssl") (:system :name "alexandria")) + ((:system :name "cffi-grovel") (:system :name "alexandria")) ((:system :name "cffi") (:system :name "alexandria")) ((:system :name "bordeaux-threads") (:system :name "alexandria")) ((:system :name "babel") (:system :name "alexandria"))) -("babel" ((:system :name "cffi") (:system :name "babel"))) +("babel" ((:system :name "quri") (:system :name "babel")) + ((:system :name "proc-parse") (:system :name "babel")) + ((:system :name "fast-http") (:system :name "babel")) + ((:system :name "dexador") (:system :name "babel")) + ((:system :name "cffi") (:system :name "babel"))) -("bordeaux-threads" ((:system :name "rove") (:system :name "bordeaux-threads"))) +("bordeaux-threads" + ((:system :name "dexador") (:system :name "bordeaux-threads")) + ((:system :name "cl+ssl") (:system :name "bordeaux-threads"))) -("cffi" ((:system :name "cl-readline") (:system :name "cffi"))) +("cffi" ((:system :name "static-vectors") (:system :name "cffi")) + ((:system :name "static-vectors") (:system :name "cffi-grovel")) + ((:system :name "osicat") (:system :name "cffi")) + ((:system :name "osicat") (:system :name "cffi-grovel")) + ((:system :name "cl+ssl") (:system :name "cffi")) + ((:system :name "cffi-toolchain") (:system :name "cffi")) + ((:system :name "cffi-grovel") (:system :name "cffi")) + ((:system :name "cffi-grovel") (:system :name "cffi-toolchain"))) -("cl-readline" ((:system :name "oneliners.cli") (:system :name "cl-readline"))) +("chipz" ((:system :name "dexador") (:system :name "chipz"))) -("dissect" ((:system :name "rove") (:system :name "dissect"))) +("chunga" ((:system :name "dexador") (:system :name "chunga"))) -("oneliners.cli.asd" - ((:system :name "oneliners.cli/tests") (:system :name "oneliners.cli")) - (t (:asd-file :name "oneliners.cli.asd"))) +("cl+ssl" ((:system :name "dexador") (:system :name "cl+ssl"))) -("rove" ((:system :name "oneliners.cli/tests") (:system :name "rove"))) +("cl-base64" ((:system :name "dexador") (:system :name "cl-base64"))) -("trivial-features" ((:system :name "cffi") (:system :name "trivial-features")) +("cl-cookie" ((:system :name "dexador") (:system :name "cl-cookie"))) + +("cl-ppcre" ((:system :name "dexador") (:system :name "cl-ppcre")) + ((:system :name "cl-cookie") (:system :name "cl-ppcre"))) + +("cl-utilities" ((:system :name "quri") (:system :name "cl-utilities")) + ((:system :name "fast-http") (:system :name "cl-utilities"))) + +("dexador" ((:system :name "oneliners.cli") (:system :name "dexador"))) + +("fast-http" ((:system :name "dexador") (:system :name "fast-http"))) + +("fast-io" ((:system :name "dexador") (:system :name "fast-io"))) + +("flexi-streams" + ((:system :name "smart-buffer") (:system :name "flexi-streams")) + ((:system :name "cl+ssl") (:system :name "flexi-streams"))) + +("local-time" ((:system :name "cl-cookie") (:system :name "local-time"))) + +("oneliners.cli.asd" (t (:asd-file :name "oneliners.cli.asd"))) + +("osicat" ((:system :name "oneliners.cli") (:system :name "osicat"))) + +("proc-parse" ((:system :name "fast-http") (:system :name "proc-parse")) + ((:system :name "cl-cookie") (:system :name "proc-parse"))) + +("quri" ((:system :name "dexador") (:system :name "quri")) + ((:system :name "cl-cookie") (:system :name "quri"))) + +("smart-buffer" ((:system :name "fast-http") (:system :name "smart-buffer"))) + +("split-sequence" ((:system :name "usocket") (:system :name "split-sequence")) + ((:system :name "quri") (:system :name "split-sequence"))) + +("static-vectors" ((:system :name "fast-io") (:system :name "static-vectors"))) + +("trivial-clipboard" + ((:system :name "oneliners.cli") (:system :name "trivial-clipboard"))) + +("trivial-features" + ((:system :name "osicat") (:system :name "trivial-features")) + ((:system :name "dexador") (:system :name "trivial-features")) + ((:system :name "cl+ssl") (:system :name "trivial-features")) + ((:system :name "cffi") (:system :name "trivial-features")) ((:system :name "babel") (:system :name "trivial-features"))) +("trivial-garbage" ((:system :name "cl+ssl") (:system :name "trivial-garbage"))) + ("trivial-gray-streams" - ((:system :name "rove") (:system :name "trivial-gray-streams"))) + ((:system :name "flexi-streams") (:system :name "trivial-gray-streams")) + ((:system :name "fast-io") (:system :name "trivial-gray-streams")) + ((:system :name "dexador") (:system :name "trivial-gray-streams")) + ((:system :name "cl+ssl") (:system :name "trivial-gray-streams")) + ((:system :name "chunga") (:system :name "trivial-gray-streams"))) + +("trivial-mimes" ((:system :name "dexador") (:system :name "trivial-mimes"))) ("unix-opts" ((:system :name "oneliners.cli") (:system :name "unix-opts"))) +("usocket" ((:system :name "dexador") (:system :name "usocket")) + ((:system :name "cl+ssl") (:system :name "usocket"))) + +("xsubseq" ((:system :name "smart-buffer") (:system :name "xsubseq")) + ((:system :name "fast-http") (:system :name "xsubseq"))) + diff --git a/oneliners.cli.asd b/oneliners.cli.asd index aa24f4c..f8c2fa8 100644 --- a/oneliners.cli.asd +++ b/oneliners.cli.asd @@ -2,7 +2,9 @@ :version "0.1.0" :author "Colin Okay" :license "AGPLv3" - :depends-on ("cl-readline" + :depends-on ("trivial-clipboard" + "dexador" + "osicat" "unix-opts") :components ((:module "src" :components @@ -10,13 +12,4 @@ :description "" :in-order-to ((test-op (test-op "oneliners.cli/tests")))) -(defsystem "oneliners.cli/tests" - :author "Colin Okay" - :license "AGPLv3" - :depends-on ("oneliners.cli" - "rove") - :components ((:module "tests" - :components - ((:file "main")))) - :description "Test system for oneliners.cli" - :perform (test-op (op c) (symbol-call :rove :run c))) + diff --git a/src/main.lisp b/src/main.lisp index 649c140..8d7db60 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -1,5 +1,32 @@ +;;;; main.lisp -- oneliners.cli entrypoint + (defpackage oneliners.cli (:use :cl)) (in-package :oneliners.cli) -;; blah blah blah. +;;; UTILITIES + +(defun parent-process-name () + "Prints the name of the parent process of the current process." + (let ((ppidfile (format nil "/proc/~a/status" (osicat-posix:getppid)))) + (first (last + (ppcre:split "\\s" + (with-open-file (input ppidfile) + (read-line input))))))) + +(defun run-with-shell + (command + &key + (shell-name (parent-process-name)) + (await-output-p t) + (output-stream *standard-output*)) + (let ((shell + (uiop:launch-program shell-name :input :stream :output :stream))) + (write-line command (uiop:process-info-input shell)) + (finish-output (uiop:process-info-input shell)) + (when await-output-p + (loop until (listen (uiop:process-info-output shell))) + (loop while (listen (uiop:process-info-output shell)) + do (princ (read-line (uiop:process-info-output shell)) output-stream) + (terpri output-stream))))) + |