(helpCmd *Command, args *Args)
| 49 | } |
| 50 | |
| 51 | func runHelp(helpCmd *Command, args *Args) { |
| 52 | if args.IsParamsEmpty() { |
| 53 | args.AfterFn(func() error { |
| 54 | ui.Println(helpText) |
| 55 | return nil |
| 56 | }) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | p := utils.NewArgsParser() |
| 61 | p.RegisterBool("--all", "-a") |
| 62 | p.RegisterBool("--plain-text") |
| 63 | p.RegisterBool("--man", "-m") |
| 64 | p.RegisterBool("--web", "-w") |
| 65 | p.Parse(args.Params) |
| 66 | |
| 67 | if p.Bool("--all") { |
| 68 | args.AfterFn(func() error { |
| 69 | ui.Printf("\nhub custom commands\n\n %s\n", strings.Join(customCommands(), " ")) |
| 70 | return nil |
| 71 | }) |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | isWeb := func() bool { |
| 76 | if p.Bool("--web") { |
| 77 | return true |
| 78 | } |
| 79 | if p.Bool("--man") { |
| 80 | return false |
| 81 | } |
| 82 | if f, err := git.Config("help.format"); err == nil { |
| 83 | return f == "web" || f == "html" |
| 84 | } |
| 85 | return false |
| 86 | } |
| 87 | |
| 88 | cmdName := "" |
| 89 | if words := args.Words(); len(words) > 0 { |
| 90 | cmdName = words[0] |
| 91 | } |
| 92 | |
| 93 | if cmdName == "hub" { |
| 94 | err := displayManPage("hub", args, isWeb()) |
| 95 | utils.Check(err) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | foundCmd := lookupCmd(cmdName) |
| 100 | if foundCmd == nil { |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | if p.Bool("--plain-text") { |
| 105 | ui.Println(foundCmd.HelpText()) |
| 106 | os.Exit(0) |
| 107 | } |
| 108 |
nothing calls this directly
no test coverage detected
searching dependent graphs…