aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/app.lisp62
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