Remove flags section from noms help. #1791

This commit is contained in:
Dan Willhite
2016-06-10 17:07:05 -07:00
parent e97dab4b34
commit 67bbdad7eb

View File

@@ -21,9 +21,12 @@ const (
func usage() {
fmt.Fprintf(os.Stderr, "usage: %s command [command-args]\n\n", path.Base(os.Args[0]))
fmt.Fprintf(os.Stderr, "Flags:\n\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nCommands:\n\n")
if hasDefinedFlags(flag.CommandLine) {
fmt.Fprintf(os.Stderr, "Flags:\n\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n")
}
fmt.Fprintf(os.Stderr, "Commands:\n\n")
fmt.Fprintf(os.Stderr, " %s\n", strings.Join(listCmds(), "\n "))
fmt.Fprintf(os.Stderr, "\nSee noms <command> -h for information on each available command.\n\n")
}
@@ -47,6 +50,13 @@ func main() {
executeCmd(cmd)
}
func hasDefinedFlags(fs *flag.FlagSet) (hasFlags bool) {
fs.VisitAll(func(*flag.Flag) {
hasFlags = true
})
return
}
func findCmd(name string) (cmd string) {
nomsName := cmdPrefix + name
forEachDir(func(dir *os.File) (stop bool) {