aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/app.lisp189
-rw-r--r--lib/oneliner.lisp5
-rw-r--r--lib/state.lisp4
-rw-r--r--lib/util.lisp7
4 files changed, 113 insertions, 92 deletions
diff --git a/app/app.lisp b/app/app.lisp
index 0684824..784d887 100644
--- a/app/app.lisp
+++ b/app/app.lisp
@@ -215,10 +215,14 @@ Their meaning is as follows:
(text :contents "Print information about a contributor."))
(group (:header "EDITOR CONFIGURATION" :hidden t)
(text :contents +configure-your-edtior+))
- (group (:header "VARIABLES IN ONELINERS")
+ (group (:header "VARIABLES IN ONELINERS" :hidden t)
(text :contents +oneliners-variables-help-text+))
- (group (:header "ICONS IN PRINTOUT")
+ (group (:header "ICONS IN PRINTOUT" :hidden t)
(text :contents +icons-in-printout-docs+))
+ (group (:header "VERSION" :hidden t)
+ (text :contents "Usage: ol version")
+ (text :contents " ")
+ (text :contents "Prints the version of this client."))
(group (:header "HELP MENU")
(text :contents "Usage: ol help [SECTION]")
(text :contents " ")
@@ -233,10 +237,10 @@ Their meaning is as follows:
'("search" "run" "clip" "show" "new" "edit"
"delete" "drafts" "trash" "publish" "flag"
"lock" "redeem" "invite" "login" "whois"
- "password" "signature"))))
+ "password" "signature" "version"))))
(text :contents " ")
(text :contents "Additional topics include:")
-(text :contents
+ (text :contents
(str:join
#\newline
(tabulate-strings
@@ -272,92 +276,97 @@ than the users."
(or (parse-integer (first args) :junk-allowed t)
(first args)))))
(cli:with-local-state
- (ecase (a:make-keyword (string-upcase command))
- (:help
- (princ #\newline)
- (help-topic (or (first args) "help")))
- (:search
- (cond
- ;; if there are args, use them as search terms
- (args
- (cli:search-for-oneliners
- args
- (getopt :long-name "limit")
- (getopt :long-name "not-flagged")
- (getopt :long-name "all-flagged")
- (getopt :long-name "newest")))
- ;; no args, but a --newest flag, just return newest
- ((getopt :long-name "newest")
- (cli::newest-oneliners (getopt :long-name "limit")))
- ;; no args, but a --all-falgged
- ((getopt :long-name "all-flagged")
- (cli::all-flagged-oneliners (getopt :long-name "limit")))
- ;; otherwise, print help for search
- (t
- (help-topic "search")
- (uiop:quit))))
-
- (:run
- (help-and-quit-unless "run" id-or-name)
- (cli:run-item id-or-name (rest args)
- :verbose (getopt :long-name "verbose")
- :confirm (getopt :long-name "confirm")
- :timeout (getopt :long-name "timeout")
- :draftp (getopt :long-name "draft")))
- (:clip
- (help-and-quit-unless "clip" id-or-name)
- (cli:run-item id-or-name (rest args)
- :force-clip t
- :draftp (getopt :long-name "draft")))
- (:show
- (help-and-quit-unless "show" id-or-name)
- (cli:print-item-explanation id-or-name))
- (:new
- (cli:add-new-oneliner))
- (:edit
- (help-and-quit-unless "edit" id-or-name)
- (cli:edit-item id-or-name (getopt :long-name "redraft")))
- (:delete
- (help-and-quit-unless "delete" id-or-name)
- (cli::delete-item id-or-name))
- (:publish
- (help-and-quit-unless "publish" id-or-name)
- (cli::publish-draft id-or-name))
- (:trash
- (help-and-quit-unless "trash" id-or-name)
- (cli::drop-draft id-or-name))
- (:drafts
- (cli::print-drafts))
- (:flag
- (help-and-quit-unless "flag" id-or-name)
- (cli:flag-item id-or-name))
- (:unflag
- (help-and-quit-unless "flag" id-or-name)
- (cli:unflag-item id-or-name))
- (:lock
- (help-and-quit-unless "lock" id-or-name)
- (cli:lock-item id-or-name))
- (:unlock
- (help-and-quit-unless "lock" id-or-name)
- (cli:unlock-item id-or-name))
- (:redeem
- (help-and-quit-unless "redeem" (= 3 (length args)))
- (apply 'cli:redeem-invite args))
- (:invite
- (cli:request-invite-code))
- (:login
- (help-and-quit-unless "login" (= 2 (length args)))
- (apply 'cli:login args))
- (:logout
- (cli:revoke-access))
- (:password
- (help-and-quit-unless "password" (= 3 (length args)))
- (apply 'cli:change-pw args))
- (:signature
- (cli:change-signature))
- (:whois
- (help-and-quit-unless "whois" args)
- (cli:show-contributor (first args)))))))
+ (handler-case
+ (ecase (a:make-keyword (string-upcase command))
+ (:help
+ (princ #\newline)
+ (help-topic (or (first args) "help")))
+ (:version
+ (format t "ol v~a~%" +ol-version+ ))
+ (:search
+ (cond
+ ;; if there are args, use them as search terms
+ (args
+ (cli:search-for-oneliners
+ args
+ (getopt :long-name "limit")
+ (getopt :long-name "not-flagged")
+ (getopt :long-name "all-flagged")
+ (getopt :long-name "newest")))
+ ;; no args, but a --newest flag, just return newest
+ ((getopt :long-name "newest")
+ (cli::newest-oneliners (getopt :long-name "limit")))
+ ;; no args, but a --all-falgged
+ ((getopt :long-name "all-flagged")
+ (cli::all-flagged-oneliners (getopt :long-name "limit")))
+ ;; otherwise, print help for search
+ (t
+ (help-topic "search")
+ (uiop:quit))))
+
+ (:run
+ (help-and-quit-unless "run" id-or-name)
+ (cli:run-item id-or-name (rest args)
+ :verbose (getopt :long-name "verbose")
+ :confirm (getopt :long-name "confirm")
+ :timeout (getopt :long-name "timeout")
+ :draftp (getopt :long-name "draft")))
+ (:clip
+ (help-and-quit-unless "clip" id-or-name)
+ (cli:run-item id-or-name (rest args)
+ :force-clip t
+ :draftp (getopt :long-name "draft")))
+ (:show
+ (help-and-quit-unless "show" id-or-name)
+ (cli:print-item-explanation id-or-name))
+ (:new
+ (cli:add-new-oneliner))
+ (:edit
+ (help-and-quit-unless "edit" id-or-name)
+ (cli:edit-item id-or-name (getopt :long-name "redraft")))
+ (:delete
+ (help-and-quit-unless "delete" id-or-name)
+ (cli::delete-item id-or-name))
+ (:publish
+ (help-and-quit-unless "publish" id-or-name)
+ (cli::publish-draft id-or-name))
+ (:trash
+ (help-and-quit-unless "trash" id-or-name)
+ (cli::drop-draft id-or-name))
+ (:drafts
+ (cli::print-drafts))
+ (:flag
+ (help-and-quit-unless "flag" id-or-name)
+ (cli:flag-item id-or-name))
+ (:unflag
+ (help-and-quit-unless "flag" id-or-name)
+ (cli:unflag-item id-or-name))
+ (:lock
+ (help-and-quit-unless "lock" id-or-name)
+ (cli:lock-item id-or-name))
+ (:unlock
+ (help-and-quit-unless "lock" id-or-name)
+ (cli:unlock-item id-or-name))
+ (:redeem
+ (help-and-quit-unless "redeem" (= 3 (length args)))
+ (apply 'cli:redeem-invite args))
+ (:invite
+ (cli:request-invite-code))
+ (:login
+ (help-and-quit-unless "login" (= 2 (length args)))
+ (apply 'cli:login args))
+ (:logout
+ (cli:revoke-access))
+ (:password
+ (help-and-quit-unless "password" (= 3 (length args)))
+ (apply 'cli:change-pw args))
+ (:signature
+ (cli:change-signature))
+ (:whois
+ (help-and-quit-unless "whois" args)
+ (cli:show-contributor (first args))))
+ (#+sbcl sb-kernel:case-failure ()
+ (help-topic "help"))))))
(help-topic "help"))
(#+sbcl sb-sys:interactive-interrupt
#+ccl ccl:interrupt-signal-condition
diff --git a/lib/oneliner.lisp b/lib/oneliner.lisp
index 668a82c..8386fa9 100644
--- a/lib/oneliner.lisp
+++ b/lib/oneliner.lisp
@@ -75,7 +75,7 @@
(let* ((title-line-format-str
(concatenate 'string "~" (prin1-to-string *term-width*) "<[~a]~;~a~;~a~>~%"))
(tags-line-format-string
- (concatenate 'string "~" (prin1-to-string *term-width*) "<~a~;by ~a~>~%")))
+ (concatenate 'string "~" (prin1-to-string *term-width*) "<~a~;by ~a ~a~>~%")))
(loop repeat *term-width* do (princ #\_))
(terpri)
(format t title-line-format-str
@@ -87,7 +87,8 @@
(equalp "manual" (oneliner-runstyle ol))))
(format t tags-line-format-string
(format nil "tags: ~{~a~^ ~}" (oneliner-tags ol))
- (oneliner-createdby ol))
+ (oneliner-createdby ol)
+ (datestring-of-universal-time (oneliner-createdat ol)))
(loop
for x from 0 to (length (oneliner-brief ol)) by *term-width*
do (format t "~a~%"
diff --git a/lib/state.lisp b/lib/state.lisp
index 5ca5a7b..49cd5d8 100644
--- a/lib/state.lisp
+++ b/lib/state.lisp
@@ -179,5 +179,9 @@ sets the api's *host* variable. If BODY produces no errors, the "
(write-drafts-to-disk)
(write-cache-to-disk)
(write-config-to-disk))
+ (dexador.error:http-request-failed (e)
+ (format *error-output* "Operation failed. The server at ~a returned with ~a~%"
+ api:*host*
+ (dexador.error:response-status e)))
(error (e)
(format *error-output* "~a~%" e)))))
diff --git a/lib/util.lisp b/lib/util.lisp
index 4b827f1..441b2e0 100644
--- a/lib/util.lisp
+++ b/lib/util.lisp
@@ -71,6 +71,12 @@ determined by EXECUTABLE-ON-SYSTEM-P."
(if what "true" "false"))
+(defun datestring-of-universal-time (ut)
+ (multiple-value-bind
+ (sec min hour day month year) (decode-universal-time ut)
+ (declare (ignore sec min hour))
+ (format nil "~a-~2,'0d-~2,'0d" year month day)))
+
(defmacro defplist (name &rest slots)
(let* ((slots-names
(loop for slot in slots
@@ -92,3 +98,4 @@ determined by EXECUTABLE-ON-SYSTEM-P."
`(progn
,make-name-defun
,@slot-defuns)))
+