func help(args []string) { if len(args) == 0 { usage() return } if len(args) != 1 { fmt.Fprintf(os.Stdout, "usage: hg help command\n\nToo many arguments given.\n") os.Exit(0) } arg := args[0] for _, cmd := range commands { if cmd.Name() == arg { utils.Tmpl(os.Stdout, template.HelpTemplate, cmd) return } } fmt.Fprintf(os.Stdout, "Unknown help topic %#q. Run 'hg help'.\n", arg) os.Exit(0) }
func usage() { utils.Tmpl(os.Stdout, template.UsageTemplate, commands) os.Exit(0) }