curl_transcode
Version:
Transcode cURL query to various programming languages
62 lines (50 loc) • 1.42 kB
Markdown
# curl_transcode
Transcode cURL query to various programming languages. The source directory that
contains source files `.curl.sh`. Transcoding put results into the target
directory. The source file name is keep unchange, the extension is changed to
specific programming language. There are programming supported languages and
platforms:
- cURL
- Rust
- Go
- C#
- Java
- Node.js
- Python
# Quickstart
```bash
npm install curl_transcode
mkdir source target
echo '{"replace": ["API_ENDPOINT"]}' > .curl_transcode.json
echo 'API_ENDPOINT="https://foo.bar/baz"' > .env
echo 'curl -X GET "$API_ENDPOINT"' > source/get.curl.sh
npx curl_transcode source target
```
# Command
```sh
curl_transcode <source_directory> <target_directory>
```
- `source_directory` - Path to directory that contains source files `.curl.sh`.
It must be existed.
- `target_directory` - Path to directory to put result files. It must be
existed.
# Configuration
```jsonc
// File: ".curl_transcode.json".
// Support JSON5 format.
{
// List of tokens to replace by environment variable from source files
// `.curl.sh`.
//
// Default: []
//
// Example: `API_ENDPOINT` will replace token `$API_ENDPOINT` by value of
// environment variable `API_ENDPOINT`.
"replace": ["API_ENDPOINT"]
}
```
```bash
# File: ".env"
# Contains environment variables for replacing source files `.curl.sh`.
API_ENDPOINT="https://foo.bar/baz
```