From 4b390fcde69013393bae325be2e8d2f5944cd15b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 13 Mar 2022 22:23:46 -0500 Subject: tabulating help menu command listing --- app/app.lisp | 62 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 18 deletions(-) (limited to 'app/app.lisp') 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 -- cgit v1.2.3