// Command server runs the multi-provider search helper.
package main
import (
"context"
"flag"
"fmt"
"log/slog"
"os"
"os/signal"
"syscall"
"go.bigb.es/auxilia/scribe"
"sourcecraft.dev/bigbes/huntsman/internal/app"
)
// Set by goreleaser / -ldflags.
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
os.Exit(run())
}
func run() int {
configPath := flag.String("config", "config.yaml", "path to config file")
showVersion := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *showVersion {
fmt.Printf("huntsman %s (commit %s, built %s)\n", version, commit, date)
return 0
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
a, err := app.New(ctx, *configPath, app.BuildInfo{Version: version, Commit: commit, Date: date})
if err != nil {
slog.Error("startup failed", scribe.Err(err))
return 1
}
if err := a.Run(ctx); err != nil {
slog.Error("run failed", scribe.Err(err))
return 1
}
return 0
}