Skip to content

WithOnInterruptFunc should default to exiting the program #592

@panbanda

Description

@panbanda

A change was added in #507 which allowed for more graceful termination, however the default functionality does not properly exit.

package main

import (
	"fmt"

	"github.com/pterm/pterm"
)


func main() {
	list := []string{"hello", "world", "example"}

	selectedItem, _ := pterm.DefaultInteractiveSelect.
		WithDefaultText("Select an item").
		WithMaxHeight(20).
		WithOptions(list).
		Show()

	fmt.Println("selected item:", selectedItem)
}

Expected output when running Ctrl + C

$ go run main.go
Select an item [type to search]: 
> hello
  world
  example
exit status 1

Actual output:

$ go run main.go
Select an item [type to search]: 
> hello
  world
  example
selected item: hello

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions