MCPcopy Create free account
hub / github.com/google/pprof / usage

Function usage

internal/driver/commands.go:260–308  ·  view source on GitHub ↗

usage returns a string describing the pprof commands and configuration options. if commandLine is set, the output reflect cli usage.

(commandLine bool)

Source from the content-addressed store, hash-verified

258// usage returns a string describing the pprof commands and configuration
259// options. if commandLine is set, the output reflect cli usage.
260func usage(commandLine bool) string {
261 var prefix string
262 if commandLine {
263 prefix = "-"
264 }
265 fmtHelp := func(c, d string) string {
266 return fmt.Sprintf(" %-16s %s", c, strings.SplitN(d, "\n", 2)[0])
267 }
268
269 var commands []string
270 for name, cmd := range pprofCommands {
271 commands = append(commands, fmtHelp(prefix+name, cmd.description))
272 }
273 sort.Strings(commands)
274
275 var help string
276 if commandLine {
277 help = " Output formats (select at most one):\n"
278 } else {
279 help = " Commands:\n"
280 commands = append(commands, fmtHelp("o/options", "List options and their current values"))
281 commands = append(commands, fmtHelp("q/quit/exit/^D", "Exit pprof"))
282 }
283
284 help = help + strings.Join(commands, "\n") + "\n\n" +
285 " Options:\n"
286
287 // Print help for configuration options after sorting them.
288 // Collect choices for multi-choice options print them together.
289 var variables []string
290 var radioStrings []string
291 for _, f := range configFields {
292 if len(f.choices) == 0 {
293 variables = append(variables, fmtHelp(prefix+f.name, configHelp[f.name]))
294 continue
295 }
296 // Format help for for this group.
297 s := []string{fmtHelp(f.name, "")}
298 for _, choice := range f.choices {
299 s = append(s, " "+fmtHelp(prefix+choice, configHelp[choice]))
300 }
301 radioStrings = append(radioStrings, strings.Join(s, "\n"))
302 }
303 sort.Strings(variables)
304 sort.Strings(radioStrings)
305 return help + strings.Join(variables, "\n") + "\n\n" +
306 " Option groups (only set one per group):\n" +
307 strings.Join(radioStrings, "\n")
308}
309
310func reportHelp(c string, cum, redirect bool) string {
311 h := []string{

Callers 3

parseFlagsFunction · 0.85
commandHelpFunction · 0.85
ParseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…