Function: majutsu-evolog--validate-args
majutsu-evolog--validate-args is a natively compiled function defined
in majutsu-evolog.el.
Signature
(majutsu-evolog--validate-args ARGS)
Documentation
Return normalized safe evolog list ARGS or signal user-error.
Majutsu owns the revision and template arguments because they frame the row protocol. Only one limit, reverse-order switch, and graph switch are allowed.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-evolog.el
(defun majutsu-evolog--validate-args (args)
"Return normalized safe evolog list ARGS or signal `user-error'.
Majutsu owns the revision and template arguments because they frame the row
protocol. Only one limit, reverse-order switch, and graph switch are allowed."
(unless (listp args)
(user-error "Evolog arguments must be a list, got %S" args))
(let ((rest args)
(seen (make-hash-table :test #'eq))
normalized)
(while rest
(let ((arg (pop rest)))
(unless (stringp arg)
(user-error "Unsupported evolog argument: %S" arg))
(pcase-let*
((`(,kind ,value)
(cond
((string-match "\\`--limit=\\([0-9]+\\)\\'" arg)
(list 'limit
(format "--limit=%s" (match-string 1 arg))))
((member arg '("-n" "--limit"))
(let ((limit (pop rest)))
(unless (and (stringp limit)
(string-match-p "\\`[0-9]+\\'" limit))
(user-error "Invalid evolog limit: %S" limit))
(list 'limit (format "--limit=%s" limit))))
((equal arg "--reversed")
'(reversed "--reversed"))
((member arg '("-G" "--no-graph"))
'(no-graph "--no-graph"))
(t
(user-error "Unsupported evolog argument: %s" arg)))))
(when (gethash kind seen)
(user-error "Duplicate evolog argument: %s" arg))
(puthash kind t seen)
(push value normalized))))
(nreverse normalized)))