/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ package cmd import ( "fmt" "strings" "github.com/spf13/cobra" "git.st8l.com/luxolus/kdnotify/buildinfo" ) const ( rootHelp = "A program for responding to Keepalived's VRRP notify events" rootHelpLong = rootHelp + ` This is meant to be used with the 'vrrp_notify ' option, see man:keepalived.conf(5) for more.` ) func Execute() error { return rootCmd().Execute() } func rootCmd() *cobra.Command { root := &cobra.Command{ Use: "kdnotify ", Short: rootHelp, Long: rootHelpLong, Version: fullVersion(), } root.AddCommand(watchCmd()) root.PersistentFlags().String("log-level", "INFO", "Set program log level. ERROR|WARN|INFO|DEBUG") return root } func fullVersion() string { v := build.Version hash := build.ShortHash() features := build.FeaturesList() vstr := fmt.Sprintf("%s sha=%s", v, hash) if len(features) > 0 { vstr = vstr + "features=" + strings.Join(features, ",") } return vstr }