diff --git a/docs/engineering/cli-quick-reference.md b/docs/engineering/cli-quick-reference.md index 8255a4b9..02d3ab48 100644 --- a/docs/engineering/cli-quick-reference.md +++ b/docs/engineering/cli-quick-reference.md @@ -21,6 +21,9 @@ sudo mv hatch /usr/local/bin/ | `hatch mock set ` | Configure mock | `hatch mock set api -status 200 -body '{}'` | | `hatch doc generate ` | Generate OpenAPI | `hatch doc generate api > openapi.json` | | `hatch version` | Print version | `hatch version` | +| `hatch config show` | Show config | `hatch config show` | +| `hatch config set ` | Set config | `hatch config set format table` | +| `hatch completions [shell]` | Shell completions | `hatch completions bash` | ## Common Flags @@ -40,8 +43,23 @@ sudo mv hatch /usr/local/bin/ | Variable | Description | Default | |----------|-------------|---------| | `HATCH_URL` | Server URL | `http://localhost:8080` | +| `HATCH_FORMAT` | Output format | `json` | +| `NO_COLOR` | Disable colors | not set | | `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 ### Capture a Webhook @@ -99,8 +117,8 @@ hatch doc generate api/posts > posts-api.json | 1 | General error | | 2 | Invalid arguments | | 3 | Network error | -| 4 | Auth error | -| 5 | Not found | +| 4 | Server error | +| 5 | Config error | ## Troubleshooting diff --git a/docs/engineering/cli.md b/docs/engineering/cli.md index 2d8f3164..323baf9f 100644 --- a/docs/engineering/cli.md +++ b/docs/engineering/cli.md @@ -51,14 +51,28 @@ docker run --rm -it ghcr.io/elfoundation/hatch:latest --help | Variable | Description | Default | |----------|-------------|---------| | `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 All commands support these flags: - `-h, --help`: Show help for the command +- `-output FORMAT`: Output format (`json`, `table`, `compact`) - `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 ### `hatch serve` @@ -73,6 +87,16 @@ 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 ` Send a request to an endpoint and store it in Hatch. @@ -398,11 +422,95 @@ chmod +x hatch sudo mv hatch /usr/local/bin/ ``` +### `hatch config` + +Manage hatch configuration. + +**Subcommands:** + +| Subcommand | Description | +|------------|-------------| +| `config show` | Display current configuration | +| `config set ` | Set a configuration value | +| `config get ` | 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 | Variable | Description | Default | Example | |----------|-------------|---------|---------| | `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` | ## Exit Codes