From f8fb8b189df265b41b2ad5a71ceb391623d9e293 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 Jul 2022 12:56:30 +0200 Subject: [PATCH] refactor(cli): remove unused synopsis examples These can be included in their own EXAMPLES: section, and doesn't need to be treated especially. --- core/cli/help.el | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/core/cli/help.el b/core/cli/help.el index bf3431691..fbe4f14b9 100644 --- a/core/cli/help.el +++ b/core/cli/help.el @@ -265,35 +265,28 @@ OPTIONS: (options ,@opts) (required ,@(mapcar (fn! (upcase (format "`%s'" %))) (if subcommands? '(command) (alist-get '&required args)))) (optional ,@(mapcar (fn! (upcase (format "[`%s']" %)))(alist-get '&optional args))) - (rest ,@(mapcar (fn! (upcase (format "[`%s'...]" %))) (if subcommands? '(args) (alist-get '&args args)))) - (examples ,@(doom-cli-help--parse-docs (doom-cli-find cli t) "SYNOPSIS"))))) + (rest ,@(mapcar (fn! (upcase (format "[`%s'...]" %))) (if subcommands? '(args) (alist-get '&args args))))))) -(defun doom-cli-help--render-synopsis (synopsis &optional prefix with-examples?) +(defun doom-cli-help--render-synopsis (synopsis &optional prefix) (let-alist synopsis (let ((doom-print-indent 0) (prefix (or prefix "")) (command (doom-cli-command-string .command))) - (with-temp-buffer - (insert! ("%s\n\n" - (fill (concat prefix - (bold (format "%s " command)) - (markup - (join (append .options - (and .options - (or .required - .optional - .rest) - (list (dark "[--]"))) - .required - .optional - .rest)))) - 80 (1+ (length (concat prefix command)))))) - (dolist (example (if with-examples? .examples)) - (insert! ("%s\n%s\n" (markup (car example)) - (if (cdr example) - (format "%s\n" (indent (markup (cdr example)) - doom-print-indent-increment)))))) - (string-trim-right (buffer-string)))))) + (string-trim-right + (format! "%s\n\n" + (fill (concat (bold prefix) + (format "%s " command) + (markup + (join (append .options + (and .options + (or .required + .optional + .rest) + (list (dark "[--]"))) + .required + .optional + .rest)))) + 80 (1+ (length (concat prefix command))))))))) ;;; Help: arguments (defun doom-cli-help--arguments (cli &optional all?)