diff options
author | Colin Okay <okay@toyful.space> | 2022-03-13 22:23:46 -0500 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-03-13 22:23:46 -0500 |
commit | 4b390fcde69013393bae325be2e8d2f5944cd15b (patch) | |
tree | 7a526d3f083f39ec2ab8954391a9b26161df1d64 /app | |
parent | 57bae08a8b9accc1d4bfb7165080e7d5a5ef2a30 (diff) |
tabulating help menu command listing
Diffstat (limited to 'app')
-rw-r--r-- | app/app.lisp | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/app/app.lisp b/app/app.lisp index 25ac8d7..b082dee 100644 --- a/app/app.lisp +++ b/app/app.lisp @@ -71,6 +71,27 @@ export EDITOR=/usr/bin/zile ;;; CLON SYNOPSIS DEFINITION +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun group-by (n xs &optional default) + (loop for l on xs by (lambda (l) (nthcdr n l)) + when (<= n (length l)) + collect (subseq l 0 n) + else + collect (append l (loop repeat (- n (length l)) collect default)))) + + (defun tabulate-strings (line-width columns strings) + (let ((row-format + (apply 'concatenate 'string + "~" (prin1-to-string line-width) "<" + (loop for i from 0 below columns + collect "~a" + when (< i (1- columns)) + collect "~;" + else + collect "~>")))) + (loop for group in (group-by columns strings " ") + collect (apply 'format nil row-format group))))) + (defsynopsis (:postfix "COMMAND [ARGS...]") (group (:header "SEARCHING FOR ONELINERS" :hidden t) (text :contents "Usage: ol [OPTIONS] search [TERMS...]") @@ -181,24 +202,29 @@ export EDITOR=/usr/bin/zile (text :contents " ") (text :contents "Print a help menu. With no arguments, prints this help.") (text :contents "Command sections include:") - (text :contents "search") - (text :contents "run") - (text :contents "clip") - (text :contents "show") - (text :contents "new") - (text :contents "edit") - (text :contents "delete") - (text :contents "drafts") - (text :contents "trash") - (text :contents "publish") - (text :contents "flag") - (text :contents "lock") - (text :contents "redeem") - (text :contents "invite") - (text :contents "login") - (text :contents "whois") - (text :contents "password") - (text :contents "signature"))) + (text :contents + (str:join + #\newline + (tabulate-strings + 40 5 + '("search" + "run" + "clip" + "show" + "new" + "edit" + "delete" + "drafts" + "trash" + "publish" + "flag" + "lock" + "redeem" + "invite" + "login" + "whois" + "password" + "signature")))))) ;;; HELPERS |