diff --git a/README.md b/README.md index 380f63c..59c77bd 100644 --- a/README.md +++ b/README.md @@ -1,158 +1,50 @@ # curl-to-code-converter -A CLI tool that converts cURL commands into ready-to-use code snippets in multiple programming languages. Simply paste a cURL command and get clean, formatted code with proper headers, authentication, and body handling. +A CLI tool that converts cURL commands into code snippets in various programming languages. ## Features -- Convert cURL to Python (requests) -- Convert cURL to JavaScript (fetch) -- Convert cURL to Go (net/http) -- Convert cURL to Ruby (Net::HTTP) -- Convert cURL to PHP (cURL) -- Convert cURL to Java (HttpURLConnection) +- Convert cURL to Python requests code +- Convert cURL to JavaScript fetch code +- Convert cURL to Go HTTP code +- Convert cURL to Ruby Net::HTTP code - Support for headers, authentication, JSON body -- Interactive CLI with verbose output -- Output to file or stdout +- Interactive mode for pasting cURL directly +- Copy to clipboard functionality ## Installation ```bash -# Install from source -pip install -e . - -# Or install directly pip install curl-to-code-converter ``` ## Usage -### Basic Conversion - ```bash -# Convert to Python (default) curl-to-code 'curl https://api.example.com/data' - -# Convert to JavaScript -curl-to-code 'curl https://api.example.com/data' -l javascript - -# Convert to Go -curl-to-code 'curl https://api.example.com/data' -l go - -# Convert to Ruby -curl-to-code 'curl https://api.example.com/data' -l ruby - -# Convert to PHP -curl-to-code 'curl https://api.example.com/data' -l php - -# Convert to Java -curl-to-code 'curl https://api.example.com/data' -l java -``` - -### With Headers and Data - -```bash -# POST with JSON body -curl-to-code 'curl -X POST https://api.example.com -H "Content-Type: application/json" -d "{\"key\":\"value\"}"' -l python - -# With authentication -curl-to-code 'curl -u user:pass https://api.example.com' -l python - -# With custom headers +curl-to-code 'curl -X POST https://api.example.com -d "{\"key\":\"value\"}"' -l python curl-to-code 'curl -H "Authorization: Bearer token" https://api.example.com' -l javascript ``` -### Output Options +## Options -```bash -# Write to file -curl-to-code 'curl https://api.example.com' -o output.py +- `-l, --language`: Target programming language (default: python) +- `-o, --output`: Output file path +- `-v, --verbose`: Show verbose output -# Verbose output (shows parsed details) -curl-to-code 'curl https://api.example.com' --verbose -``` +## Supported Languages -## Supported Options +- Python (requests) +- JavaScript (fetch) +- Go (net/http) +- Ruby (Net::HTTP) +- PHP (cURL) +- Java (HttpURLConnection) -| Option | Description | -|--------|-------------| -| `-l, --language` | Target language (python, javascript, go, ruby, php, java) | -| `-o, --output` | Output file path | -| `-v, --verbose` | Show verbose output | +## Contributing -## Supported cURL Options - -- `-X, --request` - HTTP method -- `-H, --header` - Custom headers -- `-d, --data` - Request body -- `-u, --user` - Basic authentication -- `-A, --user-agent` - User agent header -- `--compressed` - Accept-Encoding header -- `-k, --insecure` - Skip SSL verification -- `-b, --cookie` - Cookie header - -## Examples - -### Python Output -```python -import requests - -response = requests.post( - 'https://api.example.com/data', - headers={'Content-Type': 'application/json'}, - json={'key': 'value'} -) - -print(response.status_code) -print(response.text) -``` - -### JavaScript Output -```javascript -const fetchData = async () => { - try { - const options = { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({'key': 'value'}) - }; - - const response = await fetch('https://api.example.com/data', options); - const data = await response.json(); - console.log(data); - return data; - } catch (error) { - console.error('Error:', error); - } -}; - -fetchData(); -``` - -## Development - -```bash -# Clone the repository -git clone https://7000pct.gitea.bloupla.net/7000pctAUTO/curl-to-code-converter.git -cd curl-to-code-converter - -# Install in development mode -pip install -e . - -# Run tests -pytest tests/ -v - -# Lint -ruff check . - -# Type check -mypy curl_to_code_converter --ignore-missing-imports -``` - -## Requirements - -- Python 3.7+ -- requests +Contributions welcome! Please read the contributing guidelines. ## License -MIT +MIT License