From 763d358701e69034c04d9697b65adb3c821e8180 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sat, 3 Sep 2022 21:40:17 -0500 Subject: [PATCH] Mention aliases Signed-off-by: jolheiser --- README.md | 22 ++++++++++++++++++++++ examples/README.md | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0a0e20..1387f4f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,28 @@ func main() { ``` +## Aliases + +While the stdlib doesn't directly support flag aliases, this library allows for neater generation using a special syntax. + +```go +package main + +import "flag" + +func main() { + fs := flag.NewFlagSet("myapp", flag.ExitOnError) + stringFlag := fs.String("string", "", "String flag") + fs.StringVar(stringFlag, "s", *stringFlag, "--string") +} +``` +In the above code, a second flag was registered with the special `Usage` that simply declared what the long-form flag name was. +In this scenario, `ffmd` will generate docs similar to +```text +--string,-s +``` +See the [example](examples/alias). + ## License [MIT](LICENSE) \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 1c4cb51..54807a9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,4 +5,5 @@ generated docs. - [flagset](flagset) - Using only stdlib `flag.FlagSet` - [single](single) - Using a single `ffcli.Command` -- [multiple](multiple) - Using `ffcli.Command` with multiple sub-commands \ No newline at end of file +- [multiple](multiple) - Using `ffcli.Command` with multiple sub-commands +- [alias](alias) - Using `ffcli.Command` with alias setup \ No newline at end of file