docs: complete CLI documentation with config and completions commands
Some checks are pending
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run

- Added hatch config command documentation (show, set, get, init)
- Added hatch completions command documentation (bash, zsh, fish, powershell)
- Documented HATCH_FORMAT, NO_COLOR, PORT environment variables
- Updated cli-quick-reference.md with new commands and env vars
- Configuration file locations and priority order documented

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Chris Anderson 2026-06-25 15:45:48 +02:00
parent ab3d1580b5
commit 6e472f3eea
2 changed files with 128 additions and 2 deletions

View File

@ -21,6 +21,9 @@ sudo mv hatch /usr/local/bin/
| `hatch mock set <endpoint>` | Configure mock | `hatch mock set api -status 200 -body '{}'` | | `hatch mock set <endpoint>` | Configure mock | `hatch mock set api -status 200 -body '{}'` |
| `hatch doc generate <endpoint>` | Generate OpenAPI | `hatch doc generate api > openapi.json` | | `hatch doc generate <endpoint>` | Generate OpenAPI | `hatch doc generate api > openapi.json` |
| `hatch version` | Print version | `hatch version` | | `hatch version` | Print version | `hatch version` |
| `hatch config show` | Show config | `hatch config show` |
| `hatch config set <k> <v>` | Set config | `hatch config set format table` |
| `hatch completions [shell]` | Shell completions | `hatch completions bash` |
## Common Flags ## Common Flags
@ -40,8 +43,23 @@ sudo mv hatch /usr/local/bin/
| Variable | Description | Default | | Variable | Description | Default |
|----------|-------------|---------| |----------|-------------|---------|
| `HATCH_URL` | Server URL | `http://localhost:8080` | | `HATCH_URL` | Server URL | `http://localhost:8080` |
| `HATCH_FORMAT` | Output format | `json` |
| `NO_COLOR` | Disable colors | not set |
| `PORT` | Server port | `8080` | | `PORT` | Server port | `8080` |
## Configuration File
- **Linux**: `~/.config/hatch/config.json`
- **macOS**: `~/Library/Application Support/hatch/config.json`
```bash
# Initialize config
hatch config init
# View config
hatch config show
```
## Quick Examples ## Quick Examples
### Capture a Webhook ### Capture a Webhook
@ -99,8 +117,8 @@ hatch doc generate api/posts > posts-api.json
| 1 | General error | | 1 | General error |
| 2 | Invalid arguments | | 2 | Invalid arguments |
| 3 | Network error | | 3 | Network error |
| 4 | Auth error | | 4 | Server error |
| 5 | Not found | | 5 | Config error |
## Troubleshooting ## Troubleshooting

View File

@ -51,14 +51,28 @@ docker run --rm -it ghcr.io/elfoundation/hatch:latest --help
| Variable | Description | Default | | Variable | Description | Default |
|----------|-------------|---------| |----------|-------------|---------|
| `HATCH_URL` | Hatch server URL | `http://localhost:8080` | | `HATCH_URL` | Hatch server URL | `http://localhost:8080` |
| `HATCH_FORMAT` | Output format (`json`, `table`, `compact`) | `json` |
| `NO_COLOR` | Disable colored output | not set |
| `PORT` | Server listening port | `8080` |
### Global Options ### Global Options
All commands support these flags: All commands support these flags:
- `-h, --help`: Show help for the command - `-h, --help`: Show help for the command
- `-output FORMAT`: Output format (`json`, `table`, `compact`)
- `version`: Print version information - `version`: Print version information
### Configuration File
Hatch stores configuration in a JSON file. The location depends on your OS:
- **Linux/Unix**: `~/.config/hatch/config.json`
- **macOS**: `~/Library/Application Support/hatch/config.json`
- **XDG**: `$XDG_CONFIG_HOME/hatch/config.json`
Priority: Environment variables > Config file > Defaults
## Commands ## Commands
### `hatch serve` ### `hatch serve`
@ -73,6 +87,16 @@ hatch serve
PORT=9090 hatch serve PORT=9090 hatch serve
``` ```
Start the Hatch server. This is the default command when no subcommand is specified.
```bash
# Start server on default port (8080)
hatch serve
# Start with custom port (use environment variable)
PORT=9090 hatch serve
```
### `hatch capture <url>` ### `hatch capture <url>`
Send a request to an endpoint and store it in Hatch. Send a request to an endpoint and store it in Hatch.
@ -398,11 +422,95 @@ chmod +x hatch
sudo mv hatch /usr/local/bin/ sudo mv hatch /usr/local/bin/
``` ```
### `hatch config`
Manage hatch configuration.
**Subcommands:**
| Subcommand | Description |
|------------|-------------|
| `config show` | Display current configuration |
| `config set <key> <value>` | Set a configuration value |
| `config get <key>` | Get a configuration value |
| `config init` | Create default config file |
**Configurable Keys:**
| Key | Description | Valid Values |
|-----|-------------|--------------|
| `server_url` | Hatch server URL | Any valid URL |
| `format` | Output format | `json`, `table`, `compact` |
| `no_color` | Disable colors | `true`, `false`, `1`, `0` |
| `timeout` | Request timeout (seconds) | Positive integer |
**Examples:**
```bash
# Show current configuration
hatch config show
# Set server URL
hatch config set server_url https://hatch.example.com
# Set output format to table
hatch config set format table
# Disable colored output
hatch config set no_color true
# Set timeout to 60 seconds
hatch config set timeout 60
# Get a specific value
hatch config get server_url
# Initialize config file with defaults
hatch config init
```
### `hatch completions`
Generate shell completions for hatch.
**Syntax:**
```bash
hatch completions [shell]
```
**Supported Shells:**
| Shell | Command |
|-------|----------|
| Bash | `hatch completions bash` |
| Zsh | `hatch completions zsh` |
| Fish | `hatch completions fish` |
| PowerShell | `hatch completions powershell` |
**Installation:**
```bash
# Bash - add to ~/.bashrc
hatch completions bash >> ~/.bashrc
# Zsh - add to ~/.zshrc
hatch completions zsh >> ~/.zshrc
# Fish - save to completions directory
hatch completions fish > ~/.config/fish/completions/hatch.fish
# PowerShell - add to profile
hatch completions powershell >> $PROFILE
```
## Environment Variables Reference ## Environment Variables Reference
| Variable | Description | Default | Example | | Variable | Description | Default | Example |
|----------|-------------|---------|---------| |----------|-------------|---------|---------|
| `HATCH_URL` | Hatch server URL | `http://localhost:8080` | `https://hatch.example.com` | | `HATCH_URL` | Hatch server URL | `http://localhost:8080` | `https://hatch.example.com` |
| `HATCH_FORMAT` | Output format | `json` | `table`, `compact` |
| `NO_COLOR` | Disable colored output | not set | `1` |
| `PORT` | Server listening port | `8080` | `9090` | | `PORT` | Server listening port | `8080` | `9090` |
## Exit Codes ## Exit Codes