package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/sirupsen/logrus"
	"github.com/urfave/cli/v3"

	"git.maze.io/ham/hamview/internal/cmd"
)

var logger *logrus.Logger

func main() {
	cmd := &cli.Command{
		Name:  "hamview-receiver",
		Usage: "Receiver for HAM radio protocols",
		Action: func(context.Context, *cli.Command) error {
			fmt.Println("boom! I say!")
			return nil
		},
		Flags: cmd.AllFlags("hamview-receiver.yaml"),
		Commands: []*cli.Command{
			{
				Name:   "aprsis",
				Usage:  "Start an APRS-IS proxy",
				Before: cmd.ConfigureLogging(&logger),
				Action: runAPRSIS,
			},
			{
				Name:   "meshcore",
				Usage:  "Start a MeshCore receiver",
				Before: cmd.ConfigureLogging(&logger),
				Action: runMeshCore,
			},
		},
	}

	if err := cmd.Run(context.Background(), os.Args); err != nil {
		log.Fatal(err)
	}
}

func waitForInterrupt() error {
	return cmd.WaitForInterrupt(logger, "receiver")
}
