Skip to content

Commit 0bc9af9

Browse files
Merge pull request #36 from joshrotenberg/docs/cli-reference-guide
docs: add comprehensive CLI documentation
2 parents c20d6ba + d5c62e0 commit 0bc9af9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3698
-3
lines changed

.github/workflows/mdbook.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Deploy mdBook to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
- '.github/workflows/mdbook.yml'
10+
pull_request:
11+
paths:
12+
- 'docs/**'
13+
- '.github/workflows/mdbook.yml'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: false
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup mdBook
34+
uses: peaceiris/actions-mdbook@v2
35+
with:
36+
mdbook-version: 'latest'
37+
38+
- name: Cache mdbook-lint
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.cargo/bin/mdbook-lint
42+
key: mdbook-lint-${{ runner.os }}
43+
44+
- name: Install mdbook-lint
45+
run: |
46+
command -v mdbook-lint || cargo install mdbook-lint
47+
48+
- name: Lint book (informational only)
49+
run: |
50+
cd docs
51+
mdbook-lint lint src || echo "Linting completed with warnings"
52+
continue-on-error: true
53+
54+
- name: Build book
55+
run: |
56+
cd docs
57+
mdbook build
58+
59+
- name: Upload artifact
60+
if: github.event_name != 'pull_request'
61+
uses: actions/upload-pages-artifact@v3
62+
with:
63+
path: ./docs/book
64+
65+
deploy:
66+
if: github.event_name != 'pull_request'
67+
environment:
68+
name: github-pages
69+
url: ${{ steps.deployment.outputs.page_url }}
70+
runs-on: ubuntu-latest
71+
needs: build
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4

docs/.mdbook-lint.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# mdbook-lint configuration for redisctl documentation
2+
# https://github.com/joshrotenberg/mdbook-lint
3+
4+
# Temporarily disable rules with known issues
5+
disabled-rules = [
6+
"MDBOOK010", # Math block detection - false positives with $ in shell code blocks (issue #141)
7+
"MDBOOK005", # Orphaned files - incorrectly checking outside src directory (issue #142)
8+
"MDBOOK002", # Internal link validation - false positives with existing files
9+
]
10+
11+
# Don't fail the build on warnings or errors during initial setup
12+
fail-on-warnings = false
13+
fail-on-errors = false
14+
15+
# Configure specific rules
16+
[rules.MD013]
17+
# Allow longer lines for code examples and CLI output
18+
line_length = 120
19+
20+
[rules.MD024]
21+
# Allow duplicate headings in different sections
22+
enabled = true
23+
24+
[rules.MD041]
25+
# Require first line to be a heading
26+
enabled = true
27+
28+
# Future configuration options when issues are resolved:
29+
# [rules.MDBOOK005]
30+
# search-path = "src" # Only check within src directory
31+
#
32+
# [rules.MDBOOK010]
33+
# skip-code-blocks = true # Skip math detection in code blocks

docs/CONFIGURATION_AUDIT.md

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
# Configuration & Authentication Audit
2+
3+
## Current State Analysis
4+
5+
### Authentication Methods Priority Order
6+
7+
1. **Command-line flags** (highest priority)
8+
- `--profile <name>` - Use specific profile
9+
- `--deployment <cloud|enterprise>` - Force deployment type
10+
11+
2. **Environment Variables** (second priority)
12+
- `REDISCTL_PROFILE` - Default profile name
13+
- Cloud-specific:
14+
- `REDIS_CLOUD_API_KEY` - API key
15+
- `REDIS_CLOUD_API_SECRET` - API secret
16+
- `REDIS_CLOUD_API_URL` - Custom API URL (optional)
17+
- Enterprise-specific:
18+
- `REDIS_ENTERPRISE_URL` - Cluster URL
19+
- `REDIS_ENTERPRISE_USER` - Username
20+
- `REDIS_ENTERPRISE_PASSWORD` - Password
21+
- `REDIS_ENTERPRISE_INSECURE` - Allow insecure TLS (true/false)
22+
23+
3. **Profile Configuration** (third priority)
24+
- Location varies by OS:
25+
- Linux: `~/.config/redisctl/config.toml`
26+
- macOS: `~/Library/Application Support/com.redis.redisctl/config.toml`
27+
- Windows: `%APPDATA%\redis\redisctl\config.toml`
28+
- TOML format with profiles section
29+
30+
4. **Default Profile** (lowest priority)
31+
- Set via `redisctl profile default <name>`
32+
- Stored in config file
33+
34+
### Current Pain Points
35+
36+
1. **Discovery Issues**
37+
- Users don't know where config file is stored
38+
- No way to print config file location
39+
- No command to show current active configuration
40+
41+
2. **Setup Complexity**
42+
- No guided setup for first-time users
43+
- Manual profile creation requires knowing all fields
44+
- No validation during setup
45+
46+
3. **Error Messages**
47+
- Generic "authentication failed" doesn't guide to solution
48+
- No suggestion to run setup wizard
49+
- Doesn't indicate which auth method was attempted
50+
51+
4. **Security Concerns**
52+
- Passwords stored in plain text in config
53+
- No support for credential helpers or keychains
54+
- Environment variables expose secrets in process list
55+
56+
5. **Testing & Validation**
57+
- No way to test credentials without running actual command
58+
- No dry-run mode to show what would be executed
59+
- Can't verify connection before saving profile
60+
61+
## Proposed Improvements
62+
63+
### 1. Interactive Setup Wizard
64+
65+
```bash
66+
# First-time setup
67+
$ redisctl setup
68+
Welcome to redisctl! Let's configure your Redis connection.
69+
70+
? What type of Redis deployment? (Use arrow keys)
71+
❯ Redis Cloud
72+
Redis Enterprise
73+
74+
? Enter your Redis Cloud API credentials:
75+
API Key: ********
76+
API Secret: ********
77+
78+
? Test connection? (Y/n) Y
79+
✓ Successfully connected to Redis Cloud!
80+
81+
? Save as profile? (Y/n) Y
82+
? Profile name: (production)
83+
? Set as default profile? (Y/n) Y
84+
85+
Configuration saved! You can now use: redisctl database list
86+
```
87+
88+
### 2. Authentication Testing Command
89+
90+
```bash
91+
# Test current configuration
92+
$ redisctl auth test
93+
Testing authentication...
94+
✓ Profile: production (default)
95+
✓ Type: Redis Cloud
96+
✓ API URL: https://api.redislabs.com/v1
97+
✓ Credentials: Valid
98+
✓ Permissions: Read/Write
99+
✓ Account: acme-corp (ID: 12345)
100+
101+
# Test specific profile
102+
$ redisctl auth test --profile staging
103+
Testing authentication...
104+
✗ Profile: staging
105+
✗ Type: Redis Enterprise
106+
✗ URL: https://cluster.example.com:9443
107+
✗ Error: Connection refused
108+
109+
Suggestions:
110+
- Check if the cluster URL is correct
111+
- Verify the cluster is accessible from your network
112+
- Try with --insecure flag if using self-signed certificates
113+
```
114+
115+
### 3. Configuration Management Commands
116+
117+
```bash
118+
# Show configuration details
119+
$ redisctl config show
120+
Active Configuration:
121+
Source: Environment Variables
122+
Type: Redis Enterprise
123+
URL: https://localhost:9443
124+
User: admin@redis.local
125+
126+
Available Profiles:
127+
- production (Cloud) [default]
128+
- staging (Enterprise)
129+
- local (Enterprise)
130+
131+
# Show config file location
132+
$ redisctl config path
133+
/Users/alice/Library/Application Support/com.redis.redisctl/config.toml
134+
135+
# Edit config file
136+
$ redisctl config edit
137+
# Opens in $EDITOR
138+
139+
# Export configuration (without secrets)
140+
$ redisctl config export
141+
profiles:
142+
production:
143+
type: cloud
144+
api_url: https://api.redislabs.com/v1
145+
# Credentials hidden - set via environment or prompt
146+
```
147+
148+
### 4. Improved Error Messages
149+
150+
```bash
151+
$ redisctl database list
152+
Error: Authentication failed for Redis Cloud
153+
154+
The API returned: 401 Unauthorized
155+
Current configuration source: Environment variables
156+
157+
Possible solutions:
158+
1. Check your API credentials:
159+
- REDIS_CLOUD_API_KEY is set but may be incorrect
160+
- REDIS_CLOUD_API_SECRET is set but may be incorrect
161+
162+
2. Run setup wizard:
163+
redisctl setup
164+
165+
3. Test your credentials:
166+
redisctl auth test
167+
168+
4. Use a different profile:
169+
redisctl database list --profile <name>
170+
171+
For more help: redisctl help auth
172+
```
173+
174+
### 5. Secure Credential Storage
175+
176+
```bash
177+
# Use system keychain (macOS)
178+
$ redisctl config set production --use-keychain
179+
Password will be stored in macOS Keychain
180+
181+
# Use credential helper
182+
$ redisctl config set production --credential-helper "pass show redis/production"
183+
184+
# Use 1Password CLI
185+
$ redisctl config set production --credential-helper "op read op://Redis/production/password"
186+
187+
# Prompt for password
188+
$ redisctl config set production --prompt-password
189+
Password will be requested when needed
190+
```
191+
192+
### 6. Environment Detection
193+
194+
```bash
195+
# Auto-detect Redis Enterprise in Docker
196+
$ redisctl detect
197+
Detected Redis Enterprise at https://localhost:9443
198+
Would you like to configure a profile for this cluster? (Y/n)
199+
200+
# Auto-detect from kubectl context
201+
$ redisctl detect --k8s
202+
Detected Redis Enterprise Operator in namespace 'redis'
203+
Found cluster: prod-cluster-redis-enterprise
204+
Would you like to configure a profile? (Y/n)
205+
```
206+
207+
## Implementation Plan
208+
209+
### Phase 1: Core Improvements (Priority: High)
210+
1. Add `auth test` command for credential validation
211+
2. Implement `config show` and `config path` commands
212+
3. Improve error messages with actionable suggestions
213+
4. Add `--dry-run` flag to show what would be executed
214+
215+
### Phase 2: Setup Wizard (Priority: High)
216+
1. Create interactive setup wizard using `dialoguer` or `inquire`
217+
2. Add connection testing during setup
218+
3. Support profile creation and editing
219+
4. Add migration from existing .env files
220+
221+
### Phase 3: Security Enhancements (Priority: Medium)
222+
1. Integrate with system keychains (keyring-rs)
223+
2. Support credential helpers
224+
3. Add password prompting option
225+
4. Implement secure token refresh for OAuth
226+
227+
### Phase 4: Advanced Features (Priority: Low)
228+
1. Auto-detection of local Redis instances
229+
2. Kubernetes integration for operator detection
230+
3. Import from existing redis-cli configurations
231+
4. Export to other formats (env, docker-compose)
232+
233+
## Benefits
234+
235+
1. **Reduced Setup Time**
236+
- From 10+ minutes reading docs to 1 minute wizard
237+
- No need to find correct environment variable names
238+
239+
2. **Fewer Support Issues**
240+
- Clear error messages reduce confusion
241+
- Built-in testing prevents misconfiguration
242+
- Guided setup reduces errors
243+
244+
3. **Better Security**
245+
- Passwords not stored in plain text
246+
- Integration with existing credential stores
247+
- Reduced exposure in environment variables
248+
249+
4. **Improved Developer Experience**
250+
- Similar to `aws configure` or `gcloud init`
251+
- Familiar patterns from other CLI tools
252+
- Progressive disclosure of complexity
253+
254+
## Success Metrics
255+
256+
- Setup time for new users < 2 minutes
257+
- Authentication error resolution < 1 minute
258+
- 50% reduction in auth-related support issues
259+
- 90% of users successfully connect on first attempt
260+
261+
## Comparison with Curl
262+
263+
### Current curl approach:
264+
```bash
265+
# Users need to:
266+
# 1. Find API endpoint documentation
267+
# 2. Figure out authentication headers
268+
# 3. Construct complex curl commands
269+
# 4. Parse JSON responses manually
270+
271+
curl -X GET https://api.redislabs.com/v1/subscriptions \
272+
-H "x-api-key: $REDIS_CLOUD_API_KEY" \
273+
-H "x-api-secret-key: $REDIS_CLOUD_API_SECRET" \
274+
-H "Content-Type: application/json" | jq '.'
275+
```
276+
277+
### With improved redisctl:
278+
```bash
279+
# One-time setup
280+
redisctl setup
281+
282+
# Then just:
283+
redisctl cloud subscription list
284+
```
285+
286+
The difference is dramatic - from error-prone manual API calls to simple, validated commands.

0 commit comments

Comments
 (0)