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() {
|
2021-09-13 01:14:30 +03:00
|
|
|
var err error
|
2020-08-06 20:58:47 +03:00
|
|
|
ctx, cancelFn := context.WithCancel(context.Background())
|
2021-09-13 01:14:30 +03:00
|
|
|
defer func() {
|
|
|
|
cancelFn()
|
|
|
|
if err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}()
|
2020-08-06 20:58:47 +03:00
|
|
|
|
|
|
|
go func() {
|
2020-10-20 18:05:43 +03:00
|
|
|
stopCh := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(stopCh, os.Interrupt)
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-10-20 18:05:43 +03:00
|
|
|
<-stopCh
|
2020-08-06 20:58:47 +03:00
|
|
|
cancelFn()
|
|
|
|
}()
|
|
|
|
|
2021-09-13 01:14:30 +03:00
|
|
|
err = cli.Execute(ctx, os.Stdin, os.Stdout, os.Stderr, os.Args[1:])
|
2016-10-17 07:14:01 +03:00
|
|
|
}
|