diff --git a/README.md b/README.md index ba22de6..f3ce93b 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,25 @@ All options: ```bash ~/go/src/github.com/tjhop/mango (main [ ]) -> ./mango -h + _ __ ___ __ _ _ __ __ _ ___ +| '_ ` _ \ / _` || '_ \ / _` | / _ \ +| | | | | || (_| || | | || (_| || (_) | +|_| |_| |_| \__,_||_| |_| \__, | \___/ + |___/ + Usage of ./mango: - --hostname string Custom hostname to use (default's to system hostname if unset) + -h, --help Prints help and usage information + --hostname string (Requires root) Custom hostname to use [default is system hostname] -i, --inventory.path string Path to mango configuration inventory --inventory.reload-interval string Time duration for how frequently mango will auto reload and apply the inventory [default disabled] -l, --logging.level string Logging level may be one of: [trace, debug, info, warning, error, fatal and panic] --logging.output string Logging format may be one of: [logfmt, json] (default "logfmt") -pflag: help requested + +Mango is charityware, in honor of Bram Moolenaar and out of respect for Vim. You can use and copy it as much as you like, but you are encouraged to make a donation for needy children in Uganda. Please visit the ICCF web site, available at these URLs: + +https://iccf-holland.org/ +https://www.vim.org/iccf/ +https://www.iccf.nl/ ``` ### Container Usage diff --git a/cmd/mango/mango.go b/cmd/mango/mango.go index 0a4d0d7..5ed713b 100644 --- a/cmd/mango/mango.go +++ b/cmd/mango/mango.go @@ -37,6 +37,7 @@ const ( "|_| |_| |_| \\__,_||_| |_| \\__, | \\___/\n" + " |___/\n" defaultPrometheusPort = 9555 + charitywareMsg = "\nMango is charityware, in honor of Bram Moolenaar and out of respect for Vim. You can use and copy it as much as you like, but you are encouraged to make a donation for needy children in Uganda. Please visit the ICCF web site, available at these URLs:\n\nhttps://iccf-holland.org/\nhttps://www.vim.org/iccf/\nhttps://www.iccf.nl/\n" ) var ( @@ -447,13 +448,6 @@ func cleanup(ctx context.Context, logger *slog.Logger) { } func main() { - // prep and parse flags - flag.StringP("inventory.path", "i", "", "Path to mango configuration inventory") - flag.String("inventory.reload-interval", "", "Time duration for how frequently mango will auto reload and apply the inventory [default disabled]") - flag.StringP("logging.level", "l", "", "Logging level may be one of: [trace, debug, info, warning, error, fatal and panic]") - flag.String("logging.output", "logfmt", "Logging format may be one of: [logfmt, json]") - flag.String("hostname", "", "(Requires root) Custom hostname to use [default is system hostname]") - // create root logger with default configs, parse out updated configs from flags logLevel := new(slog.LevelVar) // default to info level logging logHandlerOpts := &slog.HandlerOptions{ @@ -463,6 +457,14 @@ func main() { logger := slog.New(logHandler) rootCtx := context.Background() + // prep and parse flags + flag.StringP("inventory.path", "i", "", "Path to mango configuration inventory") + flag.String("inventory.reload-interval", "", "Time duration for how frequently mango will auto reload and apply the inventory [default disabled]") + flag.StringP("logging.level", "l", "", "Logging level may be one of: [trace, debug, info, warning, error, fatal and panic]") + flag.String("logging.output", "logfmt", "Logging format may be one of: [logfmt, json]") + flag.String("hostname", "", "(Requires root) Custom hostname to use [default is system hostname]") + flag.BoolP("help", "h", false, "Prints help and usage information") + flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\nUsage of %s:\n", programNameAsciiArt, os.Args[0]) flag.PrintDefaults() @@ -479,6 +481,12 @@ func main() { os.Exit(1) } + if viper.GetBool("help") { + flag.Usage() + fmt.Fprintf(os.Stderr, charitywareMsg) + os.Exit(0) + } + // parse log level from flag logLevelFlagVal := strings.TrimSpace(strings.ToLower(viper.GetString("logging.level"))) switch logLevelFlagVal {