Files
RTSP-Streamer/cmd/rtsp-streamer/main.go
2026-07-01 18:21:14 -05:00

59 lines
1.2 KiB
Go

// Command rtsp-streamer is a full-screen RTSP video wall for UniFi Protect
// cameras, driven by mpv under a kiosk Wayland compositor and configured from
// the command line or an interactive TUI.
package main
import (
"fmt"
"log/slog"
"os"
"github.com/lwoodard/rtsp-streamer/internal/config"
"github.com/spf13/cobra"
)
var (
cfgPath string
logLevel string
)
func main() {
root := &cobra.Command{
Use: "rtsp-streamer",
Short: "Full-screen RTSP camera wall for UniFi Protect",
SilenceUsage: true,
SilenceErrors: true,
}
root.PersistentFlags().StringVar(&cfgPath, "config", config.DefaultPath(), "path to config file")
root.PersistentFlags().StringVar(&logLevel, "log", "info", "log level: debug|info|warn|error")
root.AddCommand(
daemonCmd(),
discoverCmd(),
layoutCmd(),
statusCmd(),
tuiCmd(),
configCmd(),
)
if err := root.Execute(); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
}
func newLogger() *slog.Logger {
var lvl slog.Level
switch logLevel {
case "debug":
lvl = slog.LevelDebug
case "warn":
lvl = slog.LevelWarn
case "error":
lvl = slog.LevelError
default:
lvl = slog.LevelInfo
}
return slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: lvl}))
}