# curl-converter-cli A powerful CLI tool that converts curl commands into code snippets in multiple programming languages. ## Features - Convert curl commands to **Python**, **JavaScript**, **Go**, **Ruby**, and **PHP** - Parse and extract URL, HTTP method, headers, body data, authentication, cookies - Support for Basic Auth, Bearer Token, and API Key authentication - Handle JSON and form data automatically - Interactive CLI mode for pasting curl commands - Output to file or stdout ## Installation ```bash # Clone the repository git clone https://github.com/yourusername/curl-converter-cli.git cd curl-converter-cli # Install in development mode pip install -e . # Or install with dev dependencies pip install -e ".[dev]" ``` ## Usage ### Convert curl to Python ```bash curlconverter convert -c "curl -X POST https://api.example.com/data -d '{\"key\":\"value\"}'" -l python ``` ### Convert curl to JavaScript ```bash curlconverter convert -c "curl -H 'Authorization: Bearer token' https://api.example.com" -l javascript ``` ### Convert curl to Go ```bash curlconverter convert -c "curl -X POST -d 'name=test' https://api.example.com/users" -l go ``` ### Convert curl to Ruby ```bash curlconverter convert -c "curl -u user:pass https://api.example.com" -l ruby ``` ### Convert curl to PHP ```bash curlconverter convert -c "curl -H 'Content-Type: application/json' https://api.example.com" -l php ``` ### Interactive Mode ```bash curlconverter convert -i ``` ### List Supported Languages ```bash curlconverter languages ``` Output: ``` python - Python (requests) javascript - JavaScript (fetch) go - Go (net/http) ruby - Ruby (Net::HTTP) php - PHP (cURL) ``` ### Analyze a curl Command ```bash curlconverter analyze -c "curl https://example.com" ``` Output: ``` Parsed curl command: URL: https://example.com Method: GET ``` ### Output to File ```bash curlconverter convert -c "curl https://api.example.com" -l python -o output.py ``` ## Supported Languages | Language | Library/Module | Description | |----------|---------------|-------------| | python | requests | Python HTTP library | | javascript | fetch | Native Fetch API | | go | net/http | Go standard library | | ruby | Net::HTTP | Ruby standard library | | php | cURL | PHP extension | ## Supported curl Options - `-X, --request` - HTTP method - `-H, --header` - Custom headers - `-d, --data` - Request body data - `--data-raw` - Request body data (raw) - `-u, --user` - Basic authentication - `-b, --cookie` - Cookies - `-A, --user-agent` - User-Agent header - `-L, --location` - Follow redirects - `-s, --silent` - Silent mode ## Development ### Run Tests ```bash pytest tests/ -v ``` ### Run Tests with Coverage ```bash pytest tests/ -v --cov=curlconverter --cov-report=html ``` ## License MIT License - see [LICENSE](LICENSE) file for details.