From 35a44509fbaac759ee4d837fa3b7623182cb38f9 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 8 Apr 2015 17:02:22 -0400 Subject: [PATCH 1/2] Improve readability of usage text Separates flag and description by a newline to make it easier to read the flags with long descriptions. --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index a597b5bcf..5b607fd8a 100644 --- a/main.go +++ b/main.go @@ -317,15 +317,15 @@ func usage() { } for _, fl := range groups[groupName] { - format := " -%s=%s: " + format := " -%s=%s" if strings.Contains(fl.DefValue, " ") || fl.DefValue == "" { - format = " -%s=%q: " + format = " -%s=%q" } - flagUsage := fmt.Sprintf(format, fl.Name, fl.DefValue) + flagUsage := fmt.Sprintf(format+lineSep, fl.Name, fl.DefValue) // Format the usage text to not exceed maxLineLength characters per line. words := strings.SplitAfter(fl.Usage, " ") - lineLength := len(flagUsage) + lineLength := len(lineSep) - 1 for _, w := range words { if lineLength+len(w) > maxLineLength { flagUsage += lineSep From 7d71d354fd127f8c23fa63a195a88aa4333ea6fe Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 8 Apr 2015 17:36:15 -0400 Subject: [PATCH 2/2] Remove special listing of config.file in usage The -config.file parameter isn't required or any more special than the other flags. In order to avoid confusion, this change removes the special mention again. Instead, the error message if a config file couldn't be loaded is changed to mention the flag name. --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5b607fd8a..1deabd339 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,7 @@ type prometheus struct { func NewPrometheus() *prometheus { conf, err := config.LoadFromFile(*configFile) if err != nil { - glog.Errorf("Error loading configuration from %s: %v\n", *configFile, err) + glog.Errorf("Couldn't load configuration (-config.file=%s): %v\n", *configFile, err) os.Exit(2) } @@ -305,7 +305,7 @@ func usage() { } sort.Sort(groupsOrdered) - fmt.Fprintf(os.Stderr, "Usage: %s [options ...] -config.file=:\n\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "Usage: %s [options ...]:\n\n", os.Args[0]) const ( maxLineLength = 80