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

Add documentation for flags with custom variable names #403

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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ It is possible to mark a flag as hidden, meaning it will still function as norma
flags.MarkHidden("secretFlag")
```

## Custom flag variable names
It is possible to change the variable name used in command help output for non-boolean flags. By default, the variable name is an educated guess based on the flag type.

**Example**
```go
flags.String("normalflag", "", "unchanged variable name")
flags.String("fancyflag", "", "enter a `fancyvalue` for this flag")
flags.PrintDefaults()
```

**Output**
```
--fancyflag fancyvalue enter a fancyvalue for this flag
--normalflag string unchanged variable name
```

## Disable sorting of flags
`pflag` allows you to disable sorting of flags for help and usage message.

Expand Down