Improved default usage output to use flag.PrintDefaults().

This commit is contained in:
David Howden 2015-06-06 16:29:04 +10:00
parent 9534e41d81
commit e7f103ff85

View File

@ -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
}