Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuchunyang/curl-to-elisp
Convert cURL command to Emacs Lisp code
https://github.com/xuchunyang/curl-to-elisp
Last synced: about 1 month ago
JSON representation
Convert cURL command to Emacs Lisp code
- Host: GitHub
- URL: https://github.com/xuchunyang/curl-to-elisp
- Owner: xuchunyang
- License: gpl-3.0
- Created: 2020-03-05T12:44:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-24T10:13:25.000Z (about 4 years ago)
- Last Synced: 2024-10-16T01:45:55.622Z (3 months ago)
- Language: Emacs Lisp
- Size: 69.3 KB
- Stars: 57
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Convert cURL command to Emacs Lisp code
[![Melpa](https://melpa.org/packages/curl-to-elisp-badge.svg)](https://melpa.org/#/curl-to-elisp)_Inspired by [curl-to-Go: Convert curl commands to Go code](https://mholt.github.io/curl-to-go/)._
``` emacs-lisp
(curl-to-elisp "curl example.com")
;; =>
(url-retrieve-synchronously "http://example.com")(curl-to-elisp "curl -d 'hello world' example.com")
;; =>
(let ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")))
(url-request-data "hello world"))
(url-retrieve-synchronously "http://example.com"))
```To get started, try `M-x curl-to-elisp curl -I example.com`, the Emacs Lisp code will be pretty-printed in echo area.
## Supported curl options
The following options are supported, other options are ignored.
| Option | Note |
|-------------------------------|--------------------------------|
| `-H, --header ` | |
| `-I, --head` | |
| `-X, --request ` | |
| `-d, --data ` | does not interpret `@` as file |
| `--data-ascii ` | |
| `--data-binary ` | |
| `--data-raw ` | |
| `--data-urlencode ` | |
| `-F, --form ` | does not interpret `@` as file |
| `--form-string ` | |
| `-A, --user-agent ` | |
| `-e, --referer ` | |
| `--url ` | |
| `-u, --user ` | does not prompt for a password |
| `-s, --silent` | |### `-L`, `--location`
Regarding the location header, curl doesn't redirect unless you use `-L`,
`--location`, however, `url-retrieve[-synchronously]` DOES automatically
redirect, to inhibit redirection, let-binding `url-max-redirections`, e.g.,``` emacs-lisp
(let ((url-max-redirections 0))
(display-buffer
(url-retrieve-synchronously "http://emacs-china.org")))
```## httpie to elisp
`curl-to-elisp-httpie-to-elisp` uses [curlie](https://curlie.io/) to
transform an [httpie](https://httpie.org/)/curlie command to elisp.You need to have `curlie` binary in your path (or customize
`curl-to-elisp-curlie-binary`).## curl to [verb](https://github.com/federicotdn/verb)
`curl-to-elisp-verb` converts curl command to verb request specification.
## Dependencies
- Emacs 25.1