package cmd

import (
	"errors"
	"os"
	"os/signal"
	"syscall"

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

func AllFlags(configFile string) []cli.Flag {
	return append(ConfigFlags(configFile), LoggerFlags()...)
}

func WaitForInterrupt(logger *logrus.Logger, what string) error {
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

	logger.Infof("%s: running, interrupt with ^C", what)
	for sig := range sigs {
		return errors.New("terminating on signal " + sig.String())
	}

	return nil
}
