bd-bok: Add --yes/-y flag to bd doctor --fix for non-interactive mode

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-28 21:56:33 -08:00
parent 284d61420e
commit 9d896c3b28

View File

@@ -48,6 +48,7 @@ type doctorResult struct {
var ( var (
doctorFix bool doctorFix bool
doctorYes bool
perfMode bool perfMode bool
checkHealthMode bool checkHealthMode bool
) )
@@ -87,7 +88,8 @@ Examples:
bd doctor # Check current directory bd doctor # Check current directory
bd doctor /path/to/repo # Check specific repository bd doctor /path/to/repo # Check specific repository
bd doctor --json # Machine-readable output bd doctor --json # Machine-readable output
bd doctor --fix # Automatically fix issues bd doctor --fix # Automatically fix issues (with confirmation)
bd doctor --fix --yes # Automatically fix issues (no confirmation)
bd doctor --perf # Performance diagnostics`, bd doctor --perf # Performance diagnostics`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
// Use global jsonOutput set by PersistentPreRun // Use global jsonOutput set by PersistentPreRun
@@ -143,6 +145,7 @@ Examples:
func init() { func init() {
doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "Automatically fix issues where possible") doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "Automatically fix issues where possible")
doctorCmd.Flags().BoolVarP(&doctorYes, "yes", "y", false, "Skip confirmation prompt (for non-interactive use)")
} }
func applyFixes(result doctorResult) { func applyFixes(result doctorResult) {
@@ -165,7 +168,8 @@ func applyFixes(result doctorResult) {
fmt.Printf(" %d. %s: %s\n", i+1, issue.Name, issue.Message) fmt.Printf(" %d. %s: %s\n", i+1, issue.Name, issue.Message)
} }
// Ask for confirmation // Ask for confirmation (skip if --yes flag is set)
if !doctorYes {
fmt.Printf("\nThis will attempt to fix %d issue(s). Continue? (Y/n): ", len(fixableIssues)) fmt.Printf("\nThis will attempt to fix %d issue(s). Continue? (Y/n): ", len(fixableIssues))
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
response, err := reader.ReadString('\n') response, err := reader.ReadString('\n')
@@ -179,6 +183,7 @@ func applyFixes(result doctorResult) {
fmt.Println("Fix canceled.") fmt.Println("Fix canceled.")
return return
} }
}
// Apply fixes // Apply fixes
fmt.Println("\nApplying fixes...") fmt.Println("\nApplying fixes...")