aboutsummaryrefslogtreecommitdiff
path: root/src/main.lisp
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-12 09:13:47 -0600
committerColin Okay <okay@toyful.space>2022-02-12 09:13:47 -0600
commitaffb8c35224ba56f5f7fbd363f0755520f5c305f (patch)
tree98f04cc6cca54ba903ffd26e419178a53ef090d7 /src/main.lisp
parentb0187734d06f10ee1f8d7b40bb3325761571159b (diff)
adding unix cli option parser
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/main.lisp b/src/main.lisp
index d9cd0f5..e4916b7 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -6,9 +6,60 @@
;;; CLI OPTIONS
-;; (opts:define-opts
-;; (:name ))
+(opts:define-opts
+ (:name :add
+ :description "Intaractively add a oneliner to the a wiki."
+ :long "add")
+ (:name :tags
+ :description "A comma separated list of tags to filter search results."
+ :short #\t
+ :long "tags"
+ :arg-parser #'identity
+ :meta-var "'T1, T2, ...'")
+ (:name :limit
+ :description "An integer. The maximum number of results to return."
+ :short #\l
+ :long "limit"
+ :meta-var "N"
+ :default 10
+ :arg-parser #'parse-integer)
+ (:name :edit
+ :description "An integer, a result number. Interactively edit af command."
+ :long "edit"
+ :meta-var "RESULT"
+ :arg-parser #'parse-integer)
+ (:name :not-flagged
+ :description "Filter flagged oneliners from the search results"
+ :long "not-flagged")
+ (:name :audited-only
+ :description "Filter unaudited oneliners from the search results"
+ :long "audited-only"))
+(defparameter +help-suffix+
+ "Unless RESULT is an integer, search for oneliners that involve each command in COMMANDS.
+E.g.
+ # search for oneliners involving both 'find' and 'grep'
+ ol find grep
+
+Otherwise, when RESULT is an integer, run the oneliner with index RESULT from the most
+recent search command, and supply ARGS to that oneliner, if provided.
+E.g.
+ # run the third result from the last search with arguments foo and bar
+ ol 3 foo bar")
+
+(defun print-help ()
+ (opts:describe :prefix "Oneliners Wiki Command Line Tool"
+ :args "[[RESULT ARGS | COMMANDS]"
+ :usage-of "ol"
+ :suffix +help-suffix+))
+
+;;; CONFIG AND RESULTS FILE LOCATIONS
+
+(defun config-file ()
+ (merge-pathnames ".config/oneliners.config" (user-homedir-pathname) ))
+
+(defun last-search-file ()
+ (merge-pathnames ".last_oneliners_search" (user-homedir-pathname)))
;;; UTILITIES