Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions internal/pkg/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,15 @@ func (p *Printer) PromptForConfirmation(prompt string) error {

// Prompts the user for confirmation by pressing Enter.
//
// Returns nil only if the user (explicitly) press directly enter.
// Returns ErrAborted if the user press anything else before pressing enter.
// Returns nil if the user presses Enter.
func (p *Printer) PromptForEnter(prompt string) error {
reader := bufio.NewReaderSize(p.Cmd.InOrStdin(), 1)

reader := bufio.NewReader(p.Cmd.InOrStdin())
p.Cmd.PrintErr(prompt)
answer, err := reader.ReadByte()
_, err := reader.ReadString('\n')
if err != nil {
return fmt.Errorf("read user response: %w", err)
}

// ASCII code for Enter (newline) is 10.
if answer == 10 {
return nil
}
return errAborted
return nil
}

// Shows the content in the command's stdout using the "less" command
Expand Down