Skip to content

refactor: standardize delete confirmation pattern #25

@rianjs

Description

@rianjs

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

  1. Create shared confirm() helper in shared/prompt/ or shared/view/
  2. Standardize on cfl's approach (interactive by default, --force to skip)
  3. Support both interactive and non-interactive (CI) environments
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions