MCPcopy
hub / github.com/perkeep/perkeep / help

Function help

pkg/cmdmain/cmdmain.go:216–236  ·  view source on GitHub ↗
(mode string)

Source from the content-addressed store, hash-verified

214}
215
216func help(mode string) {
217 cmdName := os.Args[0]
218 // We can skip all the checks as they're done in Main
219 cmd := modeCommand[mode]
220 cmdFlags := modeFlags[mode]
221 cmdFlags.SetOutput(Stderr)
222 if des, ok := cmd.(describer); ok {
223 Errorf("%s\n", des.Describe())
224 }
225 Errorf("\n")
226 cmd.Usage()
227 if hasFlags(cmdFlags) {
228 cmdFlags.PrintDefaults()
229 }
230 if ex, ok := cmd.(exampler); ok {
231 Errorf("\nExamples:\n")
232 for _, example := range ex.Examples() {
233 Errorf(" %s %s %s\n", cmdName, mode, example)
234 }
235 }
236}
237
238// registerFlagOnce guards ExtraFlagRegistration. Tests may invoke
239// Main multiple times, but duplicate flag registration is fatal.

Callers 1

MainFunction · 0.70

Calls 5

ErrorfFunction · 0.85
hasFlagsFunction · 0.85
DescribeMethod · 0.65
UsageMethod · 0.65
ExamplesMethod · 0.65

Tested by

no test coverage detected