~gjabell/mfn

e3e621af42a3deb6ad50e41320204010d5a389f6 — Galen Abell 7 months ago f5eb592
Ensure at least one notifier and add list command
1 files changed, 15 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +15 -1
@@ 44,6 44,7 @@ func saveLastEntry(filepath string, id int64) error {
}

func main() {
	listNotifiers := getopt.Bool("l", false, "list available notifiers")
	showHelp := getopt.Bool("h", false, "show usage")
	showVersion := getopt.Bool("v", false, "show version")



@@ 59,7 60,7 @@ func main() {
	}

	if *showHelp {
		fmt.Println("Usage: mfn [-v] [-t endpoint] -c config")
		fmt.Println("Usage: mfn [-v] [-t endpoint] -c config [-l]")
		os.Exit(0)
	}



@@ 85,6 86,19 @@ func main() {
		notifiers["webhook"] = NewWebhook(conf)
	}

	if len(notifiers) == 0 {
		log.Fatalf("Ypu must enable at least one notifier")
	}

	if *listNotifiers {
		list := []string{}
		for n := range notifiers {
			list = append(list, n)
		}
		fmt.Printf("Available notifiers: %s\n", strings.Join(list, ", "))
		os.Exit(0)
	}

	mfn := &Mfn{
		conf:      conf,
		notifiers: notifiers,