refactor(cli): minor refactors & allow flychecker in CLIs

- Add comments to doom-cli-context-parse.
- Simplify/inline code here and there.
- Remove sacrifice to appease byte-compiler.

Thanks to a346928 there's no need to appease the byte-compiler with this
eval-when-compile hackery.

Ref: a34692826f18
This commit is contained in:
Henrik Lissner 2022-06-22 19:34:25 +02:00
parent e651547abb
commit 001065ba42
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 29 additions and 34 deletions

View file

@ -121,7 +121,9 @@ OPTIONS:
" +" " " (format "'%s'" formatted)))
" or ")))))))))
(defcli! (:root :version) ((simple? ("--simple")) &context context)
(defcli! (:root :version)
((simple? ("--simple"))
&context context)
"Show installed versions of Doom, Doom modules, and Emacs."
(doom/version)
(unless simple?
@ -359,7 +361,7 @@ The alist's CAR are lists of formatted switches plus their arguments, e.g.
'((\"`--foo'\" \"`BAR'\") ...). Their CDR is their formatted documentation."
(let* ((docs (doom-cli-help--parse-docs (doom-cli-find cli t) "OPTIONS"))
(docs (mapcar (fn! (cons (split-string (car %) ", ")
(cdr %)))
(cdr %)))
docs))
(strfmt (if noformatting? "%s" "`%s'"))
local-options
@ -408,14 +410,13 @@ The alist's CAR are lists of formatted switches plus their arguments, e.g.
(insert!
("%s%s\n%s"
(mapconcat
(fn!
(when (member "..." (cdr %))
(setq multiple? t))
(string-trim-right
(format "%s %s"
(doom-print--cli-markup (car %))
(doom-print--cli-markup
(string-join (remove "..." (cdr %)) "|")))))
(fn! (when (member "..." (cdr %))
(setq multiple? t))
(string-trim-right
(format "%s %s"
(doom-print--cli-markup (car %))
(doom-print--cli-markup
(string-join (remove "..." (cdr %)) "|")))))
switches
", ")
(if multiple? ", ..." "")