From dc8309c81d636c097ac4e634ce1df59b9ed1d5ea Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 18 Feb 2022 08:12:23 -0600 Subject: adding "topic" sections to CLI options --- build-app.lisp | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'build-app.lisp') diff --git a/build-app.lisp b/build-app.lisp index 24064e7..c7f8667 100644 --- a/build-app.lisp +++ b/build-app.lisp @@ -1,43 +1,65 @@ (asdf:load-system "oneliners.cli") (defpackage #:oneliners.cli.app - (:use #:cl #:net.didierverna.clon)) + (:use #:cl #:net.didierverna.clon) + (:local-nicknames (#:a #:alexandria))) (in-package :oneliners.cli.app) (defsynopsis (:postfix "TERMS ... | N ARGS ...") - (text :contents "This is some arbitrary text.") + (text :contents "Search for oneliner mentioning TERMS or run the Nth search result with arguments ARGS.") (group (:header "Search") - (lispobj :long-name "count" :short-name "n" + (lispobj :long-name "count" :argument-type :optional + :argument-name "Count" :default-value 10 + :description "The maximum number of results to return." :typespec 'integer) (flag :long-name "not-flagged" :description "Request that no flagged oneliners are returned.")) + (group (:header "Wiki" :hidden t) + (text :contents "This is text") + (flag :long-name "add-interactive" + :description "Interactively add a new oneliner") + (flag :long-name "update-interactive" + :description "Interactively edit a oneliner and update the wiki.")) (group (:header "Admin" :hidden t) (flag :long-name "invite" :description "Request an invite token to send to a friend.") (stropt :long-name "redeem" :argument-type :optional - :default-value "" + :default-value "DUMMY-TOKEN" :argument-name "TOKEN" :description "Redeem an invite token. Enter an interactive process of setting up a new contributor account with the inviting server")) - (group () - (enum :long-name "help" :short-name "h" - :enum '(:help :admin) - :description "print this help menu."))) + (group (:header "Help") + (flag :long-name "help" + :description "Print this help menu.") + (enum :long-name "help-topic" + :enum '(:admin :wiki :search :help) + :argument-name "TOPIC" + :description "Print help for a topic. Topics are: search, wiki, admin, help"))) +(defun find-group-with-header (header) + (loop for item in (net.didierverna.clon::items *synopsis*) + when (and (typep item 'net.didierverna.clon::group) + (string-equal header (net.didierverna.clon::header item))) + return item)) (defun main () "Entry point for our standalone application." (make-context) - (when (getopt :short-name "h") + (when (getopt :long-name "help") (help ) (uiop:quit)) + + (a:when-let (topic (getopt :long-name "help-topic")) + (help :item (find-group-with-header (symbol-name topic))) + (uiop:quit)) + (let ((arguments (remainder))) (unless arguments -- cgit v1.2.3