diff --git a/cmd/search.go b/cmd/search.go index 37835ac..1a7df14 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -17,6 +17,8 @@ package cmd import ( "fmt" "os" + "os/signal" + "syscall" "github.com/gookit/color" fuzzyfinder "github.com/ktr0731/go-fuzzyfinder" @@ -48,6 +50,15 @@ var searchCmd = &cobra.Command{ os.Exit(1) } + killSignal := make(chan os.Signal, 1) + signal.Notify(killSignal, os.Interrupt, syscall.SIGTERM) + + go func() { + <-killSignal + fmt.Println("Search stopped") + os.Exit(130) + }() + searchQuery := args[0] res, err := aqi.HTTPClient.Fetch(searchQuery) if err != nil {