package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"github.com/spf13/cobra"
)

func main() {
	ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer stop()

	rootCmd := &cobra.Command{
		Use:   "synapse-backupper",
		Short: "Synapse database backup tool",
	}
	rootCmd.SetContext(ctx)
	rootCmd.AddCommand(backupCmd)
	rootCmd.AddCommand(restoreCmd)
	rootCmd.AddCommand(runCmd)
	rootCmd.AddCommand(newKeygenCmd())
	rootCmd.AddCommand(newHealthcheckCmd())
	rootCmd.AddCommand(generateConfigCmd())

	if err := rootCmd.ExecuteContext(ctx); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
