sq/main.go

32 lines
482 B
Go
Raw Normal View History

2020-08-06 20:58:47 +03:00
// Package main contains sq's main function.
2016-10-17 07:14:01 +03:00
package main
import (
2020-08-06 20:58:47 +03:00
"context"
2016-10-17 07:14:01 +03:00
"os"
2020-08-06 20:58:47 +03:00
"os/signal"
2016-10-17 07:14:01 +03:00
2020-08-06 20:58:47 +03:00
"github.com/neilotoole/sq/cli"
2016-10-17 07:14:01 +03:00
)
func main() {
var err error
2020-08-06 20:58:47 +03:00
ctx, cancelFn := context.WithCancel(context.Background())
defer func() {
cancelFn()
if err != nil {
os.Exit(1)
}
}()
2020-08-06 20:58:47 +03:00
go func() {
stopCh := make(chan os.Signal, 1)
signal.Notify(stopCh, os.Interrupt)
2020-08-06 20:58:47 +03:00
<-stopCh
2020-08-06 20:58:47 +03:00
cancelFn()
}()
err = cli.Execute(ctx, os.Stdin, os.Stdout, os.Stderr, os.Args[1:])
2016-10-17 07:14:01 +03:00
}