Files
example-eino/adk/main.go
T

50 lines
691 B
Go

package main
import (
"context"
"errors"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"example.com/ueino/adk/internal/config"
"example.com/ueino/adk/internal/terminal"
)
var (
err error
cfg config.Config
)
func main() {
if cfg, err = config.Parse(os.Args[1:]); err != nil {
if errors.Is(err, flag.ErrHelp) {
return
}
log.Print(err)
os.Exit(1)
}
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()
done := make(chan error, 1)
go func() {
done <- terminal.Run(ctx, cfg)
}()
select {
case <-ctx.Done():
fmt.Println()
case err := <-done:
if err != nil {
log.Print(err)
os.Exit(1)
}
}
}