usage message

The short help text a command prints to standard error when it is run wrongly, showing its syntax and options.

In more detail

In Go the flag package generates it from your declarations; replace flag.Usage to add a first line, and call flag.PrintDefaults to list the options. Pair it with exit code 2 so scripts can tell misuse from a failed check.

Example

flag.Usage = func() {
	fmt.Fprintln(os.Stderr, "usage: probe [flags] host...")
	flag.PrintDefaults()
}

Related terms

Taught in

References