Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document how backquotes are handled in usage messages #395

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ func Set(name, value string) error {
}

// PrintDefaults prints, to standard error unless configured
// otherwise, the default values of all defined flags in the set.
// otherwise, the default values of all defined flags in the set. See the
// documentation for the global function PrintDefaults for more information.
func (f *FlagSet) PrintDefaults() {
usages := f.FlagUsages()
fmt.Fprint(f.Output(), usages)
Expand Down Expand Up @@ -759,6 +760,17 @@ func (f *FlagSet) FlagUsages() string {
}

// PrintDefaults prints to standard error the default values of all defined command-line flags.
//
// The listed type can be changed by placing a back-quoted name in the flag's
// usage string; the first such item in the message is taken to be a parameter
// name to show in the message and the back quotes are stripped from the
// message when displayed. For instance, given
//
// flag.String("I", "", "search `directory` for include files")
//
// the output will be
//
// -I directory search directory for include files.
func PrintDefaults() {
CommandLine.PrintDefaults()
}
Expand Down