A command-line tool for making HTTP requests to third-party APIs with configurable API keys and settings. Built with Go for easy distribution and maintenance.
- π Easy Distribution: Single binary with no dependencies
- π§ Configurable: YAML-based configuration for API keys and settings
- π HTTP Client: Built-in HTTP client with proper error handling
- π CLI Interface: Professional command-line interface using Cobra
- π Secure: API key masking and secure configuration handling
Download the appropriate binary for your platform from the releases page and place it in your PATH.
# Clone the repository
git clone <repository-url>
cd iago
# Build the binary
make build
# Or build for all platforms
make build-all-
First Run: The tool will create a default configuration file
./iago config
-
Edit Configuration: Update
config.yamlwith your API settingsapi_key: "your-actual-api-key" base_url: "https://api.yourservice.com" timeout: 30 user_agent: "iago-cli/1.0"
-
Make API Requests:
# GET request ./iago get /users # With verbose output ./iago get /users --verbose
# Show help
iago --help
# Test the tool
iago hello
# Show current configuration
iago config
# Make a GET request
iago get /endpoint
# Make requests with verbose output
iago get /endpoint --verbose
# Use custom config file
iago config --config /path/to/config.yamlThe tool looks for configuration files in the following order:
./config.yaml(current directory)./config.yml(current directory)~/.iago.yaml(home directory)~/.iago.yml(home directory)
# Iago CLI Configuration
api_key: "your-api-key-here" # Required: Your API key
base_url: "https://api.example.com" # Required: Base URL for API requests
timeout: 30 # Optional: Request timeout in seconds (default: 30)
user_agent: "iago-cli/1.0" # Optional: User agent stringiago/
βββ main.go # Entry point
βββ go.mod # Go module file
βββ config/
β βββ config.go # Configuration handling
βββ api/
β βββ client.go # HTTP client for API calls
βββ cmd/
β βββ root.go # Root command and global flags
β βββ hello.go # Hello command
β βββ config.go # Config command
β βββ get.go # GET request command
βββ config.yaml # Example config file
βββ Makefile # Build system
βββ README.md # This file
# Build for current platform
make build
# Build for all platforms
make build-all
# Run the application
make run
# Run tests
make test
# Format code
make fmt
# Clean build artifacts
make clean- Create a new file in the
cmd/directory (e.g.,cmd/post.go) - Define your command using Cobra
- Add it to the root command in
init()
Example:
package cmd
import (
"github.com/spf13/cobra"
)
var postCmd = &cobra.Command{
Use: "post [path]",
Short: "Make a POST request",
Run: func(cmd *cobra.Command, args []string) {
// Your command logic here
},
}
func init() {
rootCmd.AddCommand(postCmd)
}This project demonstrates several important Go concepts:
go.moddefines the module- Each directory is a package
- Import paths use the module name
type Client struct {
config *config.Config
httpClient *http.Client
}
func (c *Client) MakeRequest(opts RequestOptions) (*APIResponse, error) {
// Method implementation
}resp, err := client.Get(path, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}Go uses interfaces for polymorphism. The http.Client implements the Doer interface.
func NewClient(cfg *config.Config) *Client {
return &Client{
config: cfg,
}
}// Example for future async requests
go func() {
resp, err := client.Get(path, nil)
// Handle response
}()The api.Client provides methods for making HTTP requests:
// Create a client
client := api.NewClient(config)
// Make a GET request
resp, err := client.Get("/users", nil)
// Make a POST request
data := map[string]interface{}{
"name": "John Doe",
"email": "john@example.com",
}
resp, err := client.Post("/users", data, nil)
// Handle the response
if resp.Success {
fmt.Printf("Response: %+v\n", resp.Data)
} else {
fmt.Printf("Error: %s\n", resp.Error)
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
Iago is named after the character from Shakespeare's "Othello" - a master manipulator who orchestrates complex schemes. Just like Iago manipulates events in the play, this CLI tool helps you orchestrate API requests! π