aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-22 14:10:18 -0600
committerColin Okay <okay@toyful.space>2022-02-22 14:10:18 -0600
commit3cb79b3c6abd7607de309f410d957bba344a031e (patch)
treed0b5171f94fd479a89f209a70de853f2071282ce
parent2f977d630fad6918fe0039d22ec13d90b89a94a0 (diff)
altered prompt to use linedit
-rw-r--r--build-app.lisp4
-rw-r--r--clpmfile.lock11
-rw-r--r--oneliners.cli.asd3
-rw-r--r--src/lib.lisp53
4 files changed, 62 insertions, 9 deletions
diff --git a/build-app.lisp b/build-app.lisp
index b0405f5..284feaa 100644
--- a/build-app.lisp
+++ b/build-app.lisp
@@ -55,7 +55,7 @@ my1337pw.")
(group (:header "Wiki" :hidden t)
(flag :long-name "add"
:description "Intaractively add a oneliner and update the wiki.")
- (flag :long-name "update"
+ (flag :long-name "edit"
:description "Interactively edit a oneliner and update the wiki.")
(flag :long-name "flag"
:description "Flag a oneliner for review.")
@@ -134,6 +134,8 @@ than the users."
(cli::lock-item hist-number))
((getopt :long-name "unlock")
(cli::unlock-item hist-number))
+ ((getopt :long-name "edit")
+ (cli::edit-item hist-number))
(t
(cli::run-item hist-number (rest arguments) (getopt :long-name "clip"))))
(uiop:quit))
diff --git a/clpmfile.lock b/clpmfile.lock
index 8c3a9eb..e70d3e8 100644
--- a/clpmfile.lock
+++ b/clpmfile.lock
@@ -66,6 +66,7 @@
("flexi-streams" :version "2022-02-20" :source "quicklisp" :systems
("flexi-streams"))
("jonathan" :version "2020-09-25" :source "quicklisp" :systems ("jonathan"))
+("linedit" :version "2018-04-30" :source "quicklisp" :systems ("linedit"))
("local-time" :version "2021-01-24" :source "quicklisp" :systems ("local-time"))
("magic-ed" :version "2020-03-25" :source "quicklisp" :systems ("magic-ed"))
("named-readtables" :version "2022-02-20" :source "quicklisp" :systems
@@ -83,6 +84,7 @@
("split-sequence"))
("static-vectors" :version "2021-06-30" :source "quicklisp" :systems
("static-vectors"))
+("terminfo" :version "2021-01-24" :source "quicklisp" :systems ("terminfo"))
("trivial-clipboard" :version "2021-02-28" :source "quicklisp" :systems
("trivial-clipboard"))
("trivial-features" :version "2021-12-09" :source "quicklisp" :systems
@@ -108,6 +110,7 @@
((:system :name "quri") (:system :name "alexandria"))
((:system :name "proc-parse") (:system :name "alexandria"))
((:system :name "osicat") (:system :name "alexandria"))
+ ((:system :name "linedit") (:system :name "alexandria"))
((:system :name "fast-io") (:system :name "alexandria"))
((:system :name "fast-http") (:system :name "alexandria"))
((:system :name "dexador") (:system :name "alexandria"))
@@ -135,6 +138,7 @@
((:system :name "osicat") (:system :name "cffi"))
((:system :name "osicat") (:system :name "cffi-grovel"))
((:system :name "net.didierverna.clon.termio") (:system :name "cffi"))
+ ((:system :name "linedit") (:system :name "cffi"))
((:system :name "cl+ssl") (:system :name "cffi"))
((:system :name "cffi-toolchain") (:system :name "cffi"))
((:system :name "cffi-grovel") (:system :name "cffi"))
@@ -210,6 +214,8 @@
("jonathan" ((:system :name "oneliners.cli") (:system :name "jonathan")))
+("linedit" ((:system :name "oneliners.cli") (:system :name "linedit")))
+
("local-time" ((:system :name "cl-cookie") (:system :name "local-time")))
("magic-ed" ((:system :name "oneliners.cli") (:system :name "magic-ed")))
@@ -225,7 +231,8 @@
("oneliners.cli.asd" (t (:asd-file :name "oneliners.cli.asd")))
-("osicat" ((:system :name "oneliners.cli") (:system :name "osicat")))
+("osicat" ((:system :name "oneliners.cli") (:system :name "osicat"))
+ ((:system :name "linedit") (:system :name "osicat")))
("proc-parse" ((:system :name "jonathan") (:system :name "proc-parse"))
((:system :name "fast-http") (:system :name "proc-parse"))
@@ -241,6 +248,8 @@
("static-vectors" ((:system :name "fast-io") (:system :name "static-vectors")))
+("terminfo" ((:system :name "linedit") (:system :name "terminfo")))
+
("trivial-clipboard"
((:system :name "oneliners.cli") (:system :name "trivial-clipboard")))
diff --git a/oneliners.cli.asd b/oneliners.cli.asd
index 4ac375f..c255c1d 100644
--- a/oneliners.cli.asd
+++ b/oneliners.cli.asd
@@ -8,7 +8,8 @@
"dexador"
"osicat"
"net.didierverna.clon"
- "magic-ed"
+ "linedit"
+ "magic-ed"
"oneliners.api-client")
:components ((:module "src"
:components
diff --git a/src/lib.lisp b/src/lib.lisp
index 858675f..ca1bd81 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -93,19 +93,17 @@ the directories that appear in the value of that variable."
(defun prompt (prompt
&key
- (out-stream *standard-output*)
- (in-stream *standard-input*)
(expect (constantly t))
retry-text)
(loop
- with to-prompt = prompt
+ ;with to-prompt = prompt
with should-retry-p = t
while should-retry-p
for line = (progn
- (princ to-prompt out-stream) (force-output out-stream)
- (setf to-prompt (or retry-text prompt))
- (read-line in-stream))
+ ;(princ to-prompt out-stream) (force-output out-stream)
+ ;(setf to-prompt (or retry-text prompt))
+ (linedit:linedit :prompt prompt))
when (funcall expect line)
do (setf should-retry-p nil)
finally (return line)))
@@ -180,6 +178,8 @@ the directories that appear in the value of that variable."
(run-with-shell ol :shell-name (or (get-shell) "bash")))))
+
+
(defun run-item (item-number args &optional force-clip)
(with-cached-result (ol item-number)
(let* ((oneliner (getf ol :oneliner))
@@ -252,6 +252,47 @@ the directories that appear in the value of that variable."
(api:post--oneliner :token (api-token))
(format t "Added~%"))))
+(defun edit-item (n)
+ (ensure-config)
+ (assert (api-token) () "Cannot edit a oneliner without an api token.")
+ (with-cached-result (ol n)
+ (let* ((oneliner
+ (prompt "Oneliner: "
+ :expect 'valid-oneliner-string-p
+ :retry-text "Oneliners must contain at least one command: "))
+ (init-tags
+ (tags-from-oneliner oneliner))
+ (brief
+ (prompt "Brief Description: "
+ :expect 'valid-brief-description-p
+ :retry-text "Too long. Must be <= 72 characters: "))
+ (tags
+ (append init-tags
+ (ppcre:split " +"
+ (prompt (format nil "Tags in addition to ~{~a ~} ?" init-tags)))))
+ (runstyle
+ (string-upcase
+ (prompt "Runstyle (auto or manual): "
+ :expect 'valid-runstyle-p
+ :retry-text "Must be (auto or manual): ")))
+ (explanation
+ (when (y-or-n-p "Provide an explanation?")
+ (string-from-editor))))
+ (api:request-with
+ (:host (host)
+ :body (jonathan:to-json
+ (list :oneliner oneliner
+ :tags tags
+ :brief brief
+ :explanation explanation
+ :runstyle runstyle))
+ :content-type "application/json")
+ (api:patch--oneliner-entry-edit (getf ol :id) :token (api-token))
+ (format t "OK~%")))
+
+
+ ))
+
(defun request-invite-code ()
(ensure-config)
(api:request-with