diff --git a/README.md b/README.md index fe93d82..ee9c69c 100644 --- a/README.md +++ b/README.md @@ -116,13 +116,13 @@ See [docs/DISCOVERY.md](docs/DISCOVERY.md) for detailed information. ```bash # Discover SoundTouch devices (combines UPnP, mDNS + configured devices) -soundtouch-cli -discover +soundtouch-cli discover devices # Discover and show detailed info for all devices -soundtouch-cli -discover-all +soundtouch-cli discover devices --all # Discover with custom timeout -soundtouch-cli -discover -timeout 10s +soundtouch-cli discover devices --timeout 10s ``` #### Real-time WebSocket Events @@ -159,16 +159,16 @@ See [docs/websocket-events.md](docs/websocket-events.md) for complete WebSocket #### Device Information ```bash # Get device information by IP address -soundtouch-cli -host 192.168.1.10 -info +soundtouch-cli --host 192.168.1.10 info # With custom port and timeout -soundtouch-cli -host 192.168.1.10 -port 8090 -timeout 15s -info +soundtouch-cli --host 192.168.1.10 --port 8090 --timeout 15s info ``` #### Now Playing Status ```bash # Get current playback information -soundtouch-cli -host 192.168.1.10 -nowplaying +soundtouch-cli --host 192.168.1.10 play now # Example output: # Now Playing: @@ -187,54 +187,56 @@ soundtouch-cli -host 192.168.1.10 -nowplaying #### Audio Sources ```bash # Get available audio sources -soundtouch-cli -host 192.168.1.10:8090 -sources +soundtouch-cli --host 192.168.1.10 source list # Example output: -# Audio Sources: +# Available Audio Sources: # Device ID: ABCD1234EFGH -# Total Sources: 14 -# Ready Sources: 5 +# Ready Sources: +# • AUX IN [Local, Available] +# • user+spotify@example.com (user) [Streaming] +# • Alexa +# • Tunein +# • Local_internet_radio # -# Ready Sources: -# • AUX IN [Local, Multiroom] -# • user+spotify@example.com (user) [Remote, Multiroom, Streaming] -# • Alexa [Remote, Multiroom] -# • Tunein [Remote, Multiroom, Streaming] -# • Local_internet_radio [Remote, Multiroom, Streaming] +# All Sources: +# • AUX IN (Available) +# • SPOTIFY (Remote) +# Account: user+spotify@example.com # -# Categories: -# Spotify: 1 account(s) ready -# AUX Input: Ready -# Streaming Services: 3 ready +# Streaming Services: +# • user+spotify@example.com (user) +# • Tunein +# • Local_internet_radio ``` #### Media Controls ```bash # Basic playback controls -soundtouch-cli -host 192.168.1.10:8090 -play -soundtouch-cli -host 192.168.1.10:8090 -pause -soundtouch-cli -host 192.168.1.10:8090 -stop +soundtouch-cli --host 192.168.1.10 play start +soundtouch-cli --host 192.168.1.10 play pause +soundtouch-cli --host 192.168.1.10 play stop # Track navigation -soundtouch-cli -host 192.168.1.10:8090 -next -soundtouch-cli -host 192.168.1.10:8090 -prev +soundtouch-cli --host 192.168.1.10 play next +soundtouch-cli --host 192.168.1.10 play prev # Volume controls (key-based) -soundtouch-cli -host 192.168.1.10:8090 -volume-up -soundtouch-cli -host 192.168.1.10:8090 -volume-down +soundtouch-cli --host 192.168.1.10 key volume-up +soundtouch-cli --host 192.168.1.10 key volume-down # Preset selection -soundtouch-cli -host 192.168.1.10:8090 -preset 1 -soundtouch-cli -host 192.168.1.10:8090 -preset 6 +soundtouch-cli --host 192.168.1.10 preset --preset 1 +soundtouch-cli --host 192.168.1.10 preset --preset 6 # Generic key command -soundtouch-cli -host 192.168.1.10:8090 -key STOP +soundtouch-cli --host 192.168.1.10 key send --key STOP ``` #### Volume Management ```bash # Get current volume -soundtouch-cli -host 192.168.1.10:8090 -volume +soundtouch-cli --host 192.168.1.10 volume get # Example output: # Current Volume: @@ -243,19 +245,22 @@ soundtouch-cli -host 192.168.1.10:8090 -volume # Target Level: 50 # Muted: false -# Set specific volume (0-100, shows warning for >30) -soundtouch-cli -host 192.168.1.10:8090 -set-volume 25 -soundtouch-cli -host 192.168.1.10:8090 -set-volume 0 # Mute +# Set specific volume (0-100) +soundtouch-cli --host 192.168.1.10 volume set --level 25 +soundtouch-cli --host 192.168.1.10 volume set --level 0 # Mute # Incremental volume control -soundtouch-cli -host 192.168.1.10:8090 -inc-volume 3 -soundtouch-cli -host 192.168.1.10:8090 -dec-volume 5 +soundtouch-cli --host 192.168.1.10 volume up --amount 3 +soundtouch-cli --host 192.168.1.10 volume down --amount 5 ``` #### Device Name ```bash # Get device name -soundtouch-cli -host 192.168.1.10 -name +soundtouch-cli --host 192.168.1.10 name get + +# Set device name +soundtouch-cli --host 192.168.1.10 name set --value "My SoundTouch" # Example output: # Device Name: My SoundTouch @@ -264,7 +269,7 @@ soundtouch-cli -host 192.168.1.10 -name #### Device Capabilities ```bash # Get device capabilities -soundtouch-cli -host 192.168.1.10 -capabilities +soundtouch-cli --host 192.168.1.10 capabilities # Example output: # Device Capabilities: @@ -288,7 +293,7 @@ soundtouch-cli -host 192.168.1.10 -capabilities #### Configured Presets ```bash # Get configured presets -soundtouch-cli -host 192.168.1.10 -presets +soundtouch-cli --host 192.168.1.10 presets # Example output: # Configured Presets: @@ -308,21 +313,42 @@ soundtouch-cli -host 192.168.1.10 -presets #### System Information ```bash # Get device clock time -soundtouch-cli -host 192.168.1.10 -clock-time +soundtouch-cli --host 192.168.1.10 clock get # Set device time to current system time -soundtouch-cli -host 192.168.1.10 -set-clock-time now +soundtouch-cli --host 192.168.1.10 clock now # Get clock display settings -soundtouch-cli -host 192.168.1.10 -clock-display +soundtouch-cli --host 192.168.1.10 clock display get # Configure clock display -soundtouch-cli -host 192.168.1.10 -enable-clock -soundtouch-cli -host 192.168.1.10 -clock-format 24 -soundtouch-cli -host 192.168.1.10 -clock-brightness 75 +soundtouch-cli --host 192.168.1.10 clock display enable +soundtouch-cli --host 192.168.1.10 clock display format --format 24 +soundtouch-cli --host 192.168.1.10 clock display brightness --brightness high # Get network information -soundtouch-cli -host 192.168.1.10 -network-info +soundtouch-cli --host 192.168.1.10 network info + +# Bass control +soundtouch-cli --host 192.168.1.10 bass get +soundtouch-cli --host 192.168.1.10 bass set --level 3 +soundtouch-cli --host 192.168.1.10 bass up --amount 2 + +# Balance control +soundtouch-cli --host 192.168.1.10 balance get +soundtouch-cli --host 192.168.1.10 balance set --level -10 +soundtouch-cli --host 192.168.1.10 balance center + +# Source selection +soundtouch-cli --host 192.168.1.10 source spotify +soundtouch-cli --host 192.168.1.10 source bluetooth +soundtouch-cli --host 192.168.1.10 source select --source SPOTIFY --account user@example.com + +# Zone management +soundtouch-cli --host 192.168.1.10 zone get +soundtouch-cli --host 192.168.1.10 zone create --members 192.168.1.11,192.168.1.12 +soundtouch-cli --host 192.168.1.10 zone add --member 192.168.1.13 +soundtouch-cli --host 192.168.1.10 zone dissolve ``` ### Go Library Usage diff --git a/docs/CLI-REFERENCE.md b/docs/CLI-REFERENCE.md new file mode 100644 index 0000000..121b725 --- /dev/null +++ b/docs/CLI-REFERENCE.md @@ -0,0 +1,602 @@ +# SoundTouch CLI Reference + +**Complete command reference for the soundtouch-cli tool** + +This document provides comprehensive documentation for all available commands and options in the `soundtouch-cli` tool. + +## Overview + +The SoundTouch CLI uses a hierarchical command structure with subcommands for different operations: + +```bash +soundtouch-cli [global-flags] [command-flags] [subcommand] [subcommand-flags] +``` + +## Global Flags + +These flags can be used with any command: + +| Flag | Short | Description | Default | +|------|-------|-------------|---------| +| `--host` | `-h` | Device IP address or hostname | Required for most commands | +| `--port` | `-p` | Device port number | `8090` | +| `--timeout` | `-t` | Request timeout duration | `10s` | +| `--help` | | Show command help | | +| `--version` | `-v` | Show CLI version | | + +## Commands + +### Discovery + +Discover SoundTouch devices on the network. + +#### `discover devices` + +Discover and list all SoundTouch devices. + +```bash +soundtouch-cli discover devices [flags] +``` + +**Flags:** +- `--all`, `-a`: Show detailed information for all devices +- `--timeout`: Discovery timeout (default: 10s) + +**Examples:** +```bash +# Basic discovery +soundtouch-cli discover devices + +# Show detailed info for all discovered devices +soundtouch-cli discover devices --all + +# Discovery with custom timeout +soundtouch-cli discover devices --timeout 15s +``` + +### Device Information + +Get information about your SoundTouch device. + +#### `info` + +Get basic device information. + +```bash +soundtouch-cli --host info +``` + +**Example:** +```bash +soundtouch-cli --host 192.168.1.10 info +``` + +#### `name get|set` + +Get or set the device name. + +```bash +# Get current name +soundtouch-cli --host name get + +# Set new name +soundtouch-cli --host name set --value "My SoundTouch" +``` + +#### `capabilities` + +Get device capabilities and features. + +```bash +soundtouch-cli --host capabilities +``` + +#### `presets` + +Get configured presets. + +```bash +soundtouch-cli --host presets +``` + +### Playback Control + +Control music playback on your device. + +#### `play ` + +Playback control commands. + +```bash +# Get current playback status +soundtouch-cli --host play now + +# Start playback +soundtouch-cli --host play start + +# Pause playback +soundtouch-cli --host play pause + +# Stop playback +soundtouch-cli --host play stop + +# Next track +soundtouch-cli --host play next + +# Previous track +soundtouch-cli --host play prev +``` + +#### `preset` + +Select a preset by number. + +```bash +soundtouch-cli --host preset --preset <1-6> +``` + +**Examples:** +```bash +# Select preset 1 +soundtouch-cli --host 192.168.1.10 preset --preset 1 + +# Select preset 6 +soundtouch-cli --host 192.168.1.10 preset --preset 6 +``` + +#### `track` + +Get current track information. + +```bash +soundtouch-cli --host track +``` + +### Key Commands + +Send key commands to the device (simulates remote control). + +#### `key ` + +Send various key commands. + +```bash +# Send generic key command +soundtouch-cli --host key send --key + +# Specific key commands +soundtouch-cli --host key power +soundtouch-cli --host key mute +soundtouch-cli --host key thumbs-up +soundtouch-cli --host key thumbs-down +soundtouch-cli --host key volume-up +soundtouch-cli --host key volume-down +``` + +**Available Key Names:** +- `PLAY`, `PAUSE`, `STOP` +- `POWER`, `MUTE` +- `VOLUME_UP`, `VOLUME_DOWN` +- `PRESET_1` through `PRESET_6` +- `NEXT_TRACK`, `PREV_TRACK` +- `THUMBS_UP`, `THUMBS_DOWN` +- `SHUFFLE_ON`, `SHUFFLE_OFF` +- `REPEAT_ON`, `REPEAT_OFF` + +### Volume Control + +Manage device volume. + +#### `volume ` + +Volume control commands. + +```bash +# Get current volume +soundtouch-cli --host volume get + +# Set specific volume level (0-100) +soundtouch-cli --host volume set --level <0-100> + +# Increase volume +soundtouch-cli --host volume up [--amount <1-10>] + +# Decrease volume +soundtouch-cli --host volume down [--amount <1-10>] +``` + +**Examples:** +```bash +# Get volume +soundtouch-cli --host 192.168.1.10 volume get + +# Set volume to 50 +soundtouch-cli --host 192.168.1.10 volume set --level 50 + +# Increase volume by 5 +soundtouch-cli --host 192.168.1.10 volume up --amount 5 + +# Decrease volume by 3 (default amount is 2) +soundtouch-cli --host 192.168.1.10 volume down --amount 3 +``` + +### Audio Sources + +Manage audio input sources. + +#### `source ` + +Audio source commands. + +```bash +# List available sources +soundtouch-cli --host source list + +# Select specific source +soundtouch-cli --host source select --source [--account ] + +# Quick source selection +soundtouch-cli --host source spotify +soundtouch-cli --host source bluetooth +soundtouch-cli --host source aux +``` + +**Source Names:** +- `SPOTIFY` - Spotify streaming +- `BLUETOOTH` - Bluetooth input +- `AUX` - AUX input +- `AIRPLAY` - AirPlay +- `STORED_MUSIC` - Local music library +- `INTERNET_RADIO` - Internet radio +- `PRODUCT` - Product-specific sources + +**Examples:** +```bash +# List all sources +soundtouch-cli --host 192.168.1.10 source list + +# Select Spotify +soundtouch-cli --host 192.168.1.10 source spotify + +# Select Spotify with specific account +soundtouch-cli --host 192.168.1.10 source select --source SPOTIFY --account user@example.com + +# Select Bluetooth +soundtouch-cli --host 192.168.1.10 source bluetooth +``` + +### Bass Control + +Adjust bass levels (equalizer). + +#### `bass ` + +Bass control commands. + +```bash +# Get current bass level +soundtouch-cli --host bass get + +# Set bass level (-9 to 9) +soundtouch-cli --host bass set --level <-9 to 9> + +# Increase bass +soundtouch-cli --host bass up [--amount <1-5>] + +# Decrease bass +soundtouch-cli --host bass down [--amount <1-5>] + +# Get bass capabilities +soundtouch-cli --host bass capabilities +``` + +**Examples:** +```bash +# Get current bass +soundtouch-cli --host 192.168.1.10 bass get + +# Set bass to +3 +soundtouch-cli --host 192.168.1.10 bass set --level 3 + +# Increase bass by 2 +soundtouch-cli --host 192.168.1.10 bass up --amount 2 + +# Decrease bass by 1 (default) +soundtouch-cli --host 192.168.1.10 bass down +``` + +### Balance Control + +Adjust left/right balance. + +#### `balance ` + +Balance control commands. + +```bash +# Get current balance +soundtouch-cli --host balance get + +# Set balance (-50 to 50, negative=left, positive=right) +soundtouch-cli --host balance set --level <-50 to 50> + +# Shift balance left +soundtouch-cli --host balance left [--amount <1-10>] + +# Shift balance right +soundtouch-cli --host balance right [--amount <1-10>] + +# Center balance +soundtouch-cli --host balance center +``` + +**Examples:** +```bash +# Get balance +soundtouch-cli --host 192.168.1.10 balance get + +# Set balance 10 units to the right +soundtouch-cli --host 192.168.1.10 balance set --level 10 + +# Shift left by 5 units (default) +soundtouch-cli --host 192.168.1.10 balance left + +# Center the balance +soundtouch-cli --host 192.168.1.10 balance center +``` + +### Clock and Time + +Manage device clock settings. + +#### `clock ` + +Clock control commands. + +```bash +# Get current time +soundtouch-cli --host clock get + +# Set time manually (HH:MM format) +soundtouch-cli --host clock set --time "14:30" + +# Set to current system time +soundtouch-cli --host clock now + +# Display settings +soundtouch-cli --host clock display get +soundtouch-cli --host clock display enable +soundtouch-cli --host clock display disable +soundtouch-cli --host clock display brightness --brightness +soundtouch-cli --host clock display format --format <12|24> +``` + +**Examples:** +```bash +# Get current time +soundtouch-cli --host 192.168.1.10 clock get + +# Set time to 2:30 PM +soundtouch-cli --host 192.168.1.10 clock set --time "14:30" + +# Sync with system time +soundtouch-cli --host 192.168.1.10 clock now + +# Enable clock display +soundtouch-cli --host 192.168.1.10 clock display enable + +# Set 24-hour format +soundtouch-cli --host 192.168.1.10 clock display format --format 24 + +# Set high brightness +soundtouch-cli --host 192.168.1.10 clock display brightness --brightness high +``` + +### Network Information + +Get network and connectivity information. + +#### `network ` + +Network information commands. + +```bash +# Get network information +soundtouch-cli --host network info + +# Ping the device +soundtouch-cli --host network ping + +# Get device base URL +soundtouch-cli --host network url +``` + +### Zone Management + +Manage multi-room zones (multiple speakers playing together). + +#### `zone ` + +Zone management commands. + +```bash +# Get current zone configuration +soundtouch-cli --host zone get + +# Get zone status +soundtouch-cli --host zone status + +# List zone members +soundtouch-cli --host zone members + +# Create new zone +soundtouch-cli --host zone create --members + +# Add device to zone +soundtouch-cli --host zone add --member + +# Remove device from zone +soundtouch-cli --host zone remove --member + +# Dissolve current zone +soundtouch-cli --host zone dissolve + +# Set zone configuration +soundtouch-cli --host zone set --master --members +``` + +**Examples:** +```bash +# Get current zone info +soundtouch-cli --host 192.168.1.10 zone get + +# Create zone with three speakers +soundtouch-cli --host 192.168.1.10 zone create --members 192.168.1.11,192.168.1.12 + +# Add speaker to existing zone +soundtouch-cli --host 192.168.1.10 zone add --member 192.168.1.13 + +# Remove speaker from zone +soundtouch-cli --host 192.168.1.10 zone remove --member 192.168.1.12 + +# Dissolve the zone (make all speakers independent) +soundtouch-cli --host 192.168.1.10 zone dissolve +``` + +## Common Usage Patterns + +### Quick Device Setup + +```bash +# Discover devices +soundtouch-cli discover devices + +# Get device info +soundtouch-cli --host 192.168.1.10 info + +# Set comfortable volume and start playing +soundtouch-cli --host 192.168.1.10 volume set --level 30 +soundtouch-cli --host 192.168.1.10 source spotify +soundtouch-cli --host 192.168.1.10 play start +``` + +### Daily Usage + +```bash +# Morning routine +soundtouch-cli --host 192.168.1.10 preset --preset 1 # Morning playlist +soundtouch-cli --host 192.168.1.10 volume set --level 25 + +# Pause for a call +soundtouch-cli --host 192.168.1.10 play pause + +# Resume +soundtouch-cli --host 192.168.1.10 play start + +# Evening routine +soundtouch-cli --host 192.168.1.10 preset --preset 3 # Evening playlist +soundtouch-cli --host 192.168.1.10 volume set --level 15 +``` + +### Multi-room Setup + +```bash +# Create a zone with living room as master +soundtouch-cli --host 192.168.1.10 zone create --members 192.168.1.11,192.168.1.12 + +# Control the whole zone from master +soundtouch-cli --host 192.168.1.10 volume set --level 40 +soundtouch-cli --host 192.168.1.10 source spotify +soundtouch-cli --host 192.168.1.10 preset --preset 2 + +# Later, dissolve the zone +soundtouch-cli --host 192.168.1.10 zone dissolve +``` + +### Audio Tuning + +```bash +# Get current audio settings +soundtouch-cli --host 192.168.1.10 volume get +soundtouch-cli --host 192.168.1.10 bass get +soundtouch-cli --host 192.168.1.10 balance get + +# Adjust for better sound +soundtouch-cli --host 192.168.1.10 bass set --level 2 # Slight bass boost +soundtouch-cli --host 192.168.1.10 balance set --level -5 # Slightly left +soundtouch-cli --host 192.168.1.10 volume set --level 35 # Good listening level +``` + +## Error Handling + +The CLI provides clear error messages for common issues: + +### Device Not Found +``` +Error: Failed to connect to device: connection refused +``` +**Solutions:** +- Check IP address is correct +- Ensure device is powered on +- Verify network connectivity with `soundtouch-cli --host network ping` + +### Invalid Commands +``` +Error: unknown command "volumee" for "soundtouch-cli" +``` +**Solution:** Check command spelling and structure using `--help` + +### Missing Required Flags +``` +Error: required flag "host" not set +``` +**Solution:** Provide required flags: `--host ` + +## Getting Help + +```bash +# General help +soundtouch-cli --help + +# Command-specific help +soundtouch-cli volume --help +soundtouch-cli zone --help + +# Subcommand help +soundtouch-cli volume set --help +soundtouch-cli zone create --help +``` + +## Configuration + +### Environment Variables + +You can set default values using environment variables: + +```bash +export SOUNDTOUCH_HOST=192.168.1.10 +export SOUNDTOUCH_PORT=8090 +export SOUNDTOUCH_TIMEOUT=15s + +# Now you can omit these flags +soundtouch-cli info +soundtouch-cli volume get +``` + +### Configuration File + +Create `~/.soundtouch.env`: + +``` +SOUNDTOUCH_HOST=192.168.1.10 +SOUNDTOUCH_PORT=8090 +SOUNDTOUCH_TIMEOUT=15s +SOUNDTOUCH_DISCOVERY_TIMEOUT=10s +``` + +## See Also + +- [Getting Started Guide](GETTING-STARTED.md) - Basic setup and usage +- [WebSocket Events](websocket-events.md) - Real-time monitoring +- [Zone Management](zone-management.md) - Multi-room setup +- [API Endpoints](API-Endpoints-Overview.md) - Complete API reference diff --git a/docs/GETTING-STARTED.md b/docs/GETTING-STARTED.md index 21736ee..00db570 100644 --- a/docs/GETTING-STARTED.md +++ b/docs/GETTING-STARTED.md @@ -441,16 +441,17 @@ Use the included CLI for quick testing: ```bash # Discovery -go run ./cmd/soundtouch-cli -discover +go run ./cmd/soundtouch-cli discover devices # Device info -go run ./cmd/soundtouch-cli -host 192.168.1.100 -info +go run ./cmd/soundtouch-cli --host 192.168.1.100 info # Basic controls -go run ./cmd/soundtouch-cli -host 192.168.1.100 -play -volume 50 +go run ./cmd/soundtouch-cli --host 192.168.1.100 play start +go run ./cmd/soundtouch-cli --host 192.168.1.100 volume set --level 50 -# WebSocket monitoring (separate terminal) -go run ./cmd/soundtouch-cli -host 192.168.1.100 -monitor +# WebSocket monitoring (use websocket-demo) +go run ./cmd/websocket-demo --host 192.168.1.100 ``` ### Configuration Management