Function: eca-providers--auth-info-text

eca-providers--auth-info-text is a natively compiled function defined in eca-providers.el.

Signature

(eca-providers--auth-info-text AUTH)

Documentation

Build the auth info line text from AUTH plist.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-providers.el
(defun eca-providers--auth-info-text (auth)
  "Build the auth info line text from AUTH plist."
  (let ((status (plist-get auth :status))
        (type (plist-get auth :type))
        (mode (plist-get auth :mode))
        (source (plist-get auth :source))
        (expires-at (plist-get auth :expiresAt))
        (env-var (plist-get auth :envVar)))
    (cond
     ((string= status "local") nil)
     ((string= status "unauthenticated") nil)
     (t
      (let ((parts '()))
        (when mode (push (capitalize mode) parts))
        (when (and type (not mode))
          (push (if (string= type "oauth") "OAuth" "API Key") parts))
        (cond
         ((and (string= source "env") env-var)
          (push (format "(env: %s)" env-var) parts))
         ((string= source "config") (push "(config)" parts))
         ((string= source "login") (push "(login)" parts)))
        (when expires-at
          (let ((diff (- expires-at (float-time))))
            (when (> diff 0)
              (cond
               ((<= diff 3600)
                (push (format "expires in %dm" (max 1 (/ (round diff) 60))) parts))
               ((<= diff 86400)
                (push (format "expires in %dh" (/ (round diff) 3600)) parts))
               (t
                (push (format "expires in %dd" (/ (round diff) 86400)) parts))))))
        (when (and (string= status "authenticated") (not expires-at))
          (push "active" parts))
        (string-join (nreverse parts) " · "))))))