MCPcopy
hub / github.com/mislav/hub / runHelp

Function runHelp

commands/help.go:51–112  ·  view source on GitHub ↗
(helpCmd *Command, args *Args)

Source from the content-addressed store, hash-verified

49}
50
51func 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

Callers

nothing calls this directly

Calls 15

RegisterBoolMethod · 0.95
ParseMethod · 0.95
BoolMethod · 0.95
PrintlnFunction · 0.92
NewArgsParserFunction · 0.92
PrintfFunction · 0.92
ConfigFunction · 0.92
CheckFunction · 0.92
customCommandsFunction · 0.85
displayManPageFunction · 0.85
lookupCmdFunction · 0.85
IsParamsEmptyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…