Skip to content

Commit 04081f2

Browse files
authored
Merge pull request #147 from clawscli/develop
v0.12.7
2 parents 0f2646a + 926e6e2 commit 04081f2

37 files changed

+499
-57
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Integration Test
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
vhs-test:
14+
runs-on: ubuntu-latest
15+
env:
16+
CGO_ENABLED: 0
17+
AWS_ENDPOINT_URL: http://localhost:4566
18+
AWS_ACCESS_KEY_ID: test
19+
AWS_SECRET_ACCESS_KEY: test
20+
AWS_DEFAULT_REGION: us-east-1
21+
AWS_EC2_METADATA_DISABLED: "true"
22+
steps:
23+
- uses: actions/checkout@v6
24+
25+
- uses: actions/setup-go@v6
26+
with:
27+
go-version-file: 'go.mod'
28+
cache: true
29+
30+
- name: Build
31+
run: go build -o claws ./cmd/claws
32+
33+
- name: Start LocalStack
34+
run: |
35+
docker run -d --name localstack -p 4566:4566 localstack/localstack:4.12.0
36+
echo "Waiting for LocalStack..."
37+
for i in $(seq 1 30); do
38+
if curl -s http://localhost:4566/_localstack/health | grep -qE '"s3": "(available|running)"'; then
39+
echo "LocalStack is ready"
40+
exit 0
41+
fi
42+
sleep 1
43+
done
44+
echo "LocalStack failed to start"
45+
exit 1
46+
47+
- name: Setup demo data
48+
timeout-minutes: 5
49+
run: ./scripts/localstack-demo-setup.sh
50+
51+
- name: Create AWS config for demo
52+
run: |
53+
mkdir -p ~/.aws
54+
cp scripts/demo-aws-config/config ~/.aws/config
55+
cp scripts/demo-aws-config/credentials ~/.aws/credentials
56+
57+
- name: Run VHS tapes
58+
run: |
59+
set -e
60+
for tape in docs/tapes/*.tape; do
61+
echo "=========================================="
62+
echo "Running: $tape"
63+
echo "=========================================="
64+
docker run --rm --network host \
65+
-v "$(pwd)":/vhs \
66+
-v ~/.aws:/root/.aws:ro \
67+
-e AWS_ENDPOINT_URL=http://localhost:4566 \
68+
-e AWS_EC2_METADATA_DISABLED=true \
69+
ghcr.io/charmbracelet/vhs "$tape"
70+
done
71+
72+
- name: Upload screenshots on failure
73+
if: failure()
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: vhs-screenshots
77+
path: docs/images/
78+
retention-days: 7
79+
80+
- name: Cleanup LocalStack
81+
if: always()
82+
run: docker stop localstack || true

Taskfile.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ tasks:
107107
cmds:
108108
- task: demo:record:gif
109109
- task: demo:record:themes
110+
- task: demo:record:theme-light
110111
- task: demo:record:features
112+
- task: demo:record:command-mode
111113

112114
demo:record:gif:
113115
desc: Record demo.gif only
@@ -154,6 +156,57 @@ tasks:
154156
-e AWS_EC2_METADATA_DISABLED=true \
155157
ghcr.io/charmbracelet/vhs docs/tapes/features.tape
156158
159+
demo:record:theme-light:
160+
desc: Record light theme screenshot (requires white terminal background)
161+
deps: [build, localstack:start, localstack:demo-setup]
162+
preconditions:
163+
- sh: '[ "$(uname -s)" = "Linux" ]'
164+
msg: "demo:record requires Linux (--network host not supported on macOS/Windows)"
165+
cmds:
166+
- |
167+
docker run --rm --network host \
168+
-v "$(pwd)":/vhs \
169+
-v "$(pwd)/scripts/demo-aws-config:/root/.aws:ro" \
170+
-e AWS_ENDPOINT_URL=http://localhost:4566 \
171+
-e AWS_EC2_METADATA_DISABLED=true \
172+
ghcr.io/charmbracelet/vhs docs/tapes/theme-light.tape
173+
174+
demo:record:command-mode:
175+
desc: Record command mode suggestion/completion test
176+
deps: [build, localstack:start, localstack:demo-setup]
177+
preconditions:
178+
- sh: '[ "$(uname -s)" = "Linux" ]'
179+
msg: "demo:record requires Linux (--network host not supported on macOS/Windows)"
180+
cmds:
181+
- |
182+
docker run --rm --network host \
183+
-v "$(pwd)":/vhs \
184+
-v "$(pwd)/scripts/demo-aws-config:/root/.aws:ro" \
185+
-e AWS_ENDPOINT_URL=http://localhost:4566 \
186+
-e AWS_EC2_METADATA_DISABLED=true \
187+
ghcr.io/charmbracelet/vhs docs/tapes/command-mode.tape
188+
189+
test:vhs:
190+
desc: Run all VHS tapes as integration tests
191+
deps: [build, localstack:start, localstack:demo-setup]
192+
preconditions:
193+
- sh: '[ "$(uname -s)" = "Linux" ]'
194+
msg: "test:vhs requires Linux (--network host not supported on macOS/Windows)"
195+
cmds:
196+
- |
197+
set -e
198+
for tape in docs/tapes/*.tape; do
199+
echo "=========================================="
200+
echo "Running: $tape"
201+
echo "=========================================="
202+
docker run --rm --network host \
203+
-v "$(pwd)":/vhs \
204+
-v "$(pwd)/scripts/demo-aws-config:/root/.aws:ro" \
205+
-e AWS_ENDPOINT_URL=http://localhost:4566 \
206+
-e AWS_EC2_METADATA_DISABLED=true \
207+
ghcr.io/charmbracelet/vhs "$tape"
208+
done
209+
157210
test-localstack:
158211
desc: Run integration tests with LocalStack
159212
deps: [localstack:start]

cmd/claws/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ func main() {
2626

2727
propagateAllProxy()
2828

29+
// Set custom config path (CLI flag > env var > default)
30+
configPath := opts.configFile
31+
if configPath == "" {
32+
configPath = strings.TrimSpace(os.Getenv("CLAWS_CONFIG"))
33+
}
34+
if configPath != "" {
35+
if err := config.SetConfigPath(configPath); err != nil {
36+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
37+
os.Exit(1)
38+
}
39+
}
40+
2941
fileCfg := config.File()
3042
cfg := config.Global()
3143

@@ -110,6 +122,7 @@ type cliOptions struct {
110122
envCreds bool
111123
autosave *bool
112124
logFile string
125+
configFile string
113126
service string
114127
resourceID string
115128
theme string
@@ -161,6 +174,11 @@ func parseFlagsFromArgs(args []string) cliOptions {
161174
i++
162175
opts.logFile = args[i]
163176
}
177+
case "-c", "--config":
178+
if i+1 < len(args) {
179+
i++
180+
opts.configFile = args[i]
181+
}
164182
case "-s", "--service":
165183
if i+1 < len(args) {
166184
i++
@@ -221,6 +239,8 @@ func printUsage() {
221239
fmt.Println(" Enable saving region/profile/theme to config file")
222240
fmt.Println(" --no-autosave")
223241
fmt.Println(" Disable saving region/profile/theme to config file")
242+
fmt.Println(" -c, --config <path>")
243+
fmt.Println(" Use custom config file instead of ~/.config/claws/config.yaml")
224244
fmt.Println(" -l, --log-file <path>")
225245
fmt.Println(" Enable debug logging to specified file")
226246
fmt.Println(" -t, --theme <name>")
@@ -242,6 +262,7 @@ func printUsage() {
242262
fmt.Println(" claws -r us-east-1,ap-northeast-1 Query multiple regions")
243263
fmt.Println()
244264
fmt.Println("Environment Variables:")
265+
fmt.Println(" CLAWS_CONFIG=<path> Use custom config file")
245266
fmt.Println(" CLAWS_READ_ONLY=1|true Enable read-only mode")
246267
fmt.Println(" ALL_PROXY Propagated to HTTP_PROXY/HTTPS_PROXY if not set")
247268
}

cmd/claws/main_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,25 @@ func TestParseFlags_Combined(t *testing.T) {
124124
t.Error("readOnly should be true")
125125
}
126126
}
127+
128+
func TestParseFlags_ConfigFile(t *testing.T) {
129+
tests := []struct {
130+
name string
131+
args []string
132+
expected string
133+
}{
134+
{"short flag", []string{"-c", "/path/to/config.yaml"}, "/path/to/config.yaml"},
135+
{"long flag", []string{"--config", "/custom/config.yaml"}, "/custom/config.yaml"},
136+
{"with other flags", []string{"-p", "dev", "-c", "/config.yaml", "-r", "us-east-1"}, "/config.yaml"},
137+
{"no config", []string{"-p", "dev"}, ""},
138+
}
139+
140+
for _, tt := range tests {
141+
t.Run(tt.name, func(t *testing.T) {
142+
opts := parseFlagsFromArgs(tt.args)
143+
if opts.configFile != tt.expected {
144+
t.Errorf("configFile = %q, want %q", opts.configFile, tt.expected)
145+
}
146+
})
147+
}
148+
}

docs/configuration.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,29 @@ claws uses your standard AWS configuration:
1010

1111
## Configuration File
1212

13-
Optional settings can be stored in `~/.config/claws/config.yaml`:
13+
Optional settings can be stored in `~/.config/claws/config.yaml`.
14+
15+
### Custom Config File Path
16+
17+
Use a custom config file instead of the default:
18+
19+
```bash
20+
# Via CLI flag
21+
claws -c /path/to/config.yaml
22+
claws --config ~/work/claws-work.yaml
23+
24+
# Via environment variable
25+
CLAWS_CONFIG=/path/to/config.yaml claws
26+
```
27+
28+
**Precedence:** `-c` flag > `CLAWS_CONFIG` env var > default (`~/.config/claws/config.yaml`)
29+
30+
Use cases:
31+
- Environment-specific configs (work/personal)
32+
- CI/CD with project-specific settings
33+
- Testing with different configurations
34+
35+
### Config File Format
1436

1537
```yaml
1638
timeouts:

docs/images/actions-menu.png

42.6 KB
Loading

docs/images/cmd-suggest-ec.png

78.8 KB
Loading

docs/images/cmd-suggest-ec2-c.png

87.2 KB
Loading
84.6 KB
Loading

docs/images/cmd-suggest-ec2.png

78.8 KB
Loading

0 commit comments

Comments
 (0)