package main

import (
    "flag"
    "fmt"
    "log"
    "time"

    cfgpkg "github.com/jan/fm-rds-tx/internal/config"
    offpkg "github.com/jan/fm-rds-tx/internal/offline"
)

func main() {
    configPath := flag.String("config", "", "path to JSON config")
    out := flag.String("output", "", "output IQ file path")
    duration := flag.Duration("duration", 2*time.Second, "generation duration")
    outputRate := flag.Int("output-rate", 0, "override composite output sample rate")
    flag.Parse()

    cfg, err := cfgpkg.Load(*configPath)
    if err != nil {
        log.Fatalf("load config: %v", err)
    }
    if *outputRate > 0 {
        cfg.FM.CompositeRateHz = *outputRate
    }

    gen := offpkg.NewGenerator(cfg)
    if err := gen.WriteFile(*out, *duration); err != nil {
        log.Fatalf("offline generation failed: %v", err)
    }
    fmt.Println(gen.Summary(*duration))
}
