Refactor: extract duplicated validation and flag logic (bd-g5p7)

- Created internal/validation package for centralized validation logic
- Created cmd/bd/flags.go for shared flag registration
- Updated create and update commands to use shared logic
- Added support for 'P1' style priority to update command
- Added tests for validation logic

Amp-Thread-ID: https://ampcode.com/threads/T-c8d369a3-32f0-42a0-96d1-fd589e89bd6b
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-20 19:11:27 -05:00
parent e9f5a0c35a
commit bbfedb060a
7 changed files with 102 additions and 59 deletions

View File

@@ -579,6 +579,17 @@ func TestCLI_PriorityFormats(t *testing.T) {
if issue["priority"].(float64) != 3 {
t.Errorf("Expected priority 3, got: %v", issue["priority"])
}
// Test update with P-format
id := issue["id"].(string)
runBDInProcess(t, tmpDir, "update", id, "-p", "P1")
out = runBDInProcess(t, tmpDir, "show", id, "--json")
var updated []map[string]interface{}
json.Unmarshal([]byte(out), &updated)
if updated[0]["priority"].(float64) != 1 {
t.Errorf("Expected priority 1 after update, got: %v", updated[0]["priority"])
}
}
func TestCLI_Reopen(t *testing.T) {