Function: verb--export-to-websocat
verb--export-to-websocat is a natively compiled function defined in
verb.el.
Signature
(verb--export-to-websocat RS &optional NO-MESSAGE NO-KILL)
Documentation
Export a request spec RS to websocat format.
Add the generated command to the kill ring and return it. For more information about websocat see URL https://github.com/vi/websocat. If NO-MESSAGE is non-nil, do not display a message on the minibuffer. If NO-KILL is non-nil, do not add the command to the kill ring.
Source Code
;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(defun verb--export-to-websocat (rs &optional no-message no-kill)
"Export a request spec RS to websocat format.
Add the generated command to the kill ring and return it. For more
information about websocat see URL `https://github.com/vi/websocat'.
If NO-MESSAGE is non-nil, do not display a message on the minibuffer.
If NO-KILL is non-nil, do not add the command to the kill ring."
(with-temp-buffer
(unless (string= (oref rs method) "GET")
(user-error "%s" "Can only export GET requests to websocat"))
(let ((url (concat "ws"
(string-remove-prefix
"http" (verb-request-spec-url-to-string rs)))))
(insert "websocat '" url "'"))
(dolist (key-value (oref rs headers))
(insert " \\\n")
(insert "-H '" (car key-value) ": " (cdr key-value) "'"))
(let ((result (verb--buffer-string-no-properties)))
(unless no-kill
(kill-new result))
(unless no-message
(message "Websocat command copied to the kill ring"))
;; Return the generated command.
result)))