refactor(cli): remove unused synopsis examples

These can be included in their own EXAMPLES: section, and doesn't need
to be treated especially.
This commit is contained in:
Henrik Lissner 2022-07-29 12:56:30 +02:00
parent a79b2ec69e
commit f8fb8b189d
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -265,18 +265,17 @@ 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))
(string-trim-right
(format! "%s\n\n"
(fill (concat (bold prefix)
(format "%s " command)
(markup
(join (append .options
(and .options
@ -287,13 +286,7 @@ OPTIONS:
.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))))))
80 (1+ (length (concat prefix command)))))))))
;;; Help: arguments
(defun doom-cli-help--arguments (cli &optional all?)