-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: standardize delete confirmation pattern #25
Copy link
Copy link
Closed
Description
Summary
Standardize the delete confirmation UX across both tools using interactive confirmation.
Current State
cfl (tools/cfl/internal/cmd/page/delete.go lines 75-88):
// Interactive confirmation with stdin
fmt.Printf("Are you sure you want to delete page '%s'? (y/N): ", title)
scanner := bufio.NewScanner(opts.stdin)
if scanner.Scan() {
confirm = scanner.Text()
}
if confirm != "y" && confirm != "Y" {
fmt.Println("Deletion cancelled.")
return nil
}jtk (tools/jtk/internal/cmd/issues/delete.go lines 34-41):
// Requires --force flag, no interactive option
if !force {
v.Warning("This will permanently delete issue %s...", issueKey)
return fmt.Errorf("deletion cancelled (use --force to confirm)")
}Proposed Changes
- Create shared
confirm()helper inshared/prompt/orshared/view/ - Standardize on cfl's approach (interactive by default, --force to skip)
- Support both interactive and non-interactive (CI) environments
- Update jtk delete command to use interactive confirmation
Proposed API
// shared/prompt/confirm.go
func Confirm(prompt string, stdin io.Reader) (bool, error)
func ConfirmOrForce(prompt string, force bool, stdin io.Reader) (bool, error)Benefits
- Better UX - users can confirm interactively
- Still supports scripting with --force flag
- Consistent behavior across tools
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels