A modern Swift implementation of cURL - make HTTP requests from the command line with ease!
Inspired by cURL, completely rewritten using modern Swift 6 features including async/await, structured concurrency, and Swift Argument Parser.
- Modern Swift - Built with async/await, actors, and structured concurrency
- Type-Safe CLI - Uses Swift Argument Parser for robust command-line interface
- Beautiful Output - Colored terminal output with clean formatting
- Easy to Use - Intuitive command structure similar to cURL
- Full HTTP Support - GET, POST, JSON requests with custom headers
- Concurrent Requests - Built-in support for parallel request processing
- Error Handling - Comprehensive error reporting and validation
- Swift 5.9+ (Swift 6.0 recommended)
- macOS 10.15+
- Xcode 12+ (for development)
git clone https://github.com/emrahu/sURL.git
cd sURL
swift build -c release
The executable will be available at .build/release/sURL
cp .build/release/sURL /usr/local/bin/
Get help for any command:
surl --help
surl get --help
surl json --help
# Simple GET request
surl get https://httpbin.org/get
# Include response headers
surl get --include-headers https://httpbin.org/get
# Verbose output (headers + status info)
surl get --verbose https://httpbin.org/get
# Custom headers
surl get -H "Authorization: Bearer token" -H "User-Agent: MyApp/1.0" https://api.example.com
# POST with form data
surl post --data "name=John&email=john@example.com" https://httpbin.org/post
# POST with custom headers
surl post -H "X-API-Key: secret" --data "key=value" https://api.example.com/submit
# POST JSON data (equivalent to curl -X POST -H "Content-Type: application/json" -d '{}')
surl json --data '{"name": "John", "age": 30}' https://httpbin.org/post
# JSON with custom headers and verbose output
surl json --verbose -H "Authorization: Bearer token" --data '{"query": "search"}' https://api.example.com/search
# GET with multiple custom headers and verbose output
surl get --verbose \
-H "Accept: application/json" \
-H "User-Agent: sURL/2.0" \
https://api.github.com/users/octocat
# JSON POST with authentication
surl json \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
--data '{"title": "New Post", "content": "Hello World!"}' \
https://api.example.com/posts
sURL is built with modern Swift patterns:
- Swift Argument Parser - Type-safe command-line argument parsing
- Async/Await - Modern asynchronous networking
- Actor-based NetworkManager - Thread-safe request handling
- Result Types - Robust error handling
- Protocol-Oriented Design - Clean, modular architecture
Sources/
└── sURLCore/
├── sURL.swift # Main CLI and command definitions
├── NetworkManager.swift # Async networking layer
├── NetworkTypes.swift # HTTP types and errors
├── OutputFormatter.swift# Console output formatting
└── ...
swift build
swift test
The project follows modern Swift conventions:
- Async/await for asynchronous operations
- Actor isolation for thread safety
- Result types for error handling
- Protocol-oriented design
Command | Description | Example |
---|---|---|
get |
Perform GET request | surl get https://example.com |
post |
POST with form data | surl post --data "key=value" https://example.com |
json |
POST with JSON data | surl json --data '{"key":"value"}' https://example.com |
Flag | Description |
---|---|
-h, --help |
Show help information |
--version |
Show version |
-i, --include-headers |
Include response headers |
-v, --verbose |
Verbose output |
-H, --headers |
Custom headers (format: 'Key: Value') |
- File upload/download support
- HTTP authentication methods
- Cookie handling
- Proxy support
- Response caching
- Configuration files
- Shell completion scripts
This project is actively maintained! Contributions and feedback are welcome:
sURL is open source and available under the MIT license. See the LICENSE file for more information.
- v2.0.0 - Complete rewrite with Swift 6, async/await, and modern architecture
- v1.0.0 - Initial release with basic functionality