From e7f103ff85c4167df6f8579280b2ce4c34c42f6b Mon Sep 17 00:00:00 2001 From: David Howden Date: Sat, 6 Jun 2015 16:29:04 +1000 Subject: [PATCH] Improved default usage output to use flag.PrintDefaults(). --- tag/tag.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tag/tag.go b/tag/tag.go index c565dc2..16b74e3 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -17,15 +17,22 @@ import ( var raw bool +var usage = func() { + fmt.Fprintf(os.Stderr, "usage: %s [optional flags] filename\n", os.Args[0]) + flag.PrintDefaults() +} + func init() { flag.BoolVar(&raw, "raw", false, "show raw tag data") + + flag.Usage = usage } func main() { flag.Parse() if flag.NArg() != 1 { - fmt.Printf("usage: %v filename\n", os.Args[0]) + usage() return }