feat: support multiple -p/-r flags with comma separation#111
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Fixed test isolation: extracted |
This comment was marked as outdated.
This comment was marked as outdated.
Code Review: PR #111 - Multiple Profiles/Regions SupportSummaryThis PR adds support for multiple profiles and regions via comma-separated values or repeated flags. The implementation is well-structured with comprehensive test coverage. Overall, this is a solid implementation that follows the codebase patterns well. ✅ Strengths1. Excellent Test Coverage
2. Security - Input Validation
3. Code Quality
4. Documentation
🔍 Observations & Minor Suggestions1. Order PreservationThe current implementation preserves insertion order while removing duplicates: if p = strings.TrimSpace(p); p != "" && !slices.Contains(opts.profiles, p) {
opts.profiles = append(opts.profiles, p)
}Note: 2. Consistent Logging✅ Already addressed: Updated logging to use plural forms (main.go:87): log.Info("claws started", "profiles", opts.profiles, "regions", opts.regions, "readOnly", opts.readOnly)3. Empty Flag Value HandlingCurrent behavior when flag is provided without value: case "-p", "--profile":
if i+1 < len(args) { // No error if missing valueThis silently ignores if i+1 >= len(args) {
fmt.Fprintln(os.Stderr, "Error: -p/--profile requires a value")
os.Exit(1)
}However, checking other flags in the codebase, this appears to be consistent with existing behavior (same pattern for 4. Test Coverage - IntegrationThe unit tests are excellent. Consider adding an integration test that verifies:
Example test structure: func TestApplyStartupConfig_MultipleProfiles(t *testing.T) {
opts := cliOptions{
profiles: []string{"dev", "prod"},
regions: []string{"us-east-1", "eu-west-1"},
}
cfg := config.NewConfig()
fileCfg := &config.FileConfig{}
applyStartupConfig(opts, fileCfg, cfg)
if !cfg.IsMultiProfile() {
t.Error("Expected multi-profile to be enabled")
}
// ... verify selections
}Not blocking, but would increase confidence in the integration between flag parsing and config application. 🎯 Potential Issues1. Missing Test for Combined Flags (Minor)The test Example: func TestParseFlags_AllFlags(t *testing.T) {
opts := parseFlagsFromArgs([]string{
"-p", "dev,prod",
"-r", "us-east-1,eu-west-1",
"-s", "ec2",
"-i", "i-12345",
"-ro",
"--autosave",
})
// Verify all flags parsed correctly
}Impact: Low - unlikely to have issues, but improves coverage 2. Help Text Formatting (Very Minor)The usage examples in // Before:
fmt.Println(" claws -p dev,prod Query multiple profiles")
fmt.Println(" claws -r us-east-1,ap-northeast-1 Query multiple regions")
// Suggestion - align descriptions:
fmt.Println(" claws -p dev,prod Query multiple profiles")
fmt.Println(" claws -r us-east-1,ap-northeast-1 Query multiple regions")Impact: Cosmetic only 📋 Performance Considerations✅ No concerns:
🔒 Security Considerations✅ No concerns:
📊 Test Coverage Summary
🎯 Final RecommendationApprove with minor suggestions. This is high-quality code that:
The suggestions above are optional improvements, not blocking issues. 📝 Optional Follow-ups (Non-blocking)
Great work! 🎉 |
Summary
-p dev,prod) or repeated flags (-p dev -p prod)