aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorSteve Domino <[email protected]>2015-09-04 16:22:44 -0600
committerSteve Domino <[email protected]>2015-09-07 22:43:34 -0600
commit574bc4cfb94effb3e1bb934f1512c1f1a558000f (patch)
tree9476914f0340b527cea03ff04677bd120151dcb4 /README.md
parent8e7dc108ab3a1ab6ce6d922bbaff5657b88e8e49 (diff)
adding a private field to flags, and a function for marking flags as private
removing some c/p left-overs from the MarkPrivate function, and updating the comment slightly changed field from Private to Hidden. Added documentation w/example to README.md. Added testing to confirm hidden flags updating test message
Diffstat (limited to 'README.md')
-rw-r--r--README.md27
1 files changed, 18 insertions, 9 deletions
diff --git a/README.md b/README.md
index 247ceca..e74dd50 100644
--- a/README.md
+++ b/README.md
@@ -216,24 +216,33 @@ func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
myFlagSet.SetNormalizeFunc(aliasNormalizeFunc)
```
-## Deprecating a flag or its shorthand
-It is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.
+## Deprecating a flag or its shorthand
+It is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.
-**Example #1**: You want to deprecate a flag named "badflag" as well as inform the users what flag they should use instead.
+**Example #1**: You want to deprecate a flag named "badflag" as well as inform the users what flag they should use instead.
```go
-// deprecate a flag by specifying its name and a usage message
+// deprecate a flag by specifying its name and a usage message
flags.MarkDeprecated("badflag", "please use --good-flag instead")
```
-This hides "badflag" from help text, and prints `Flag --badflag has been deprecated, please use --good-flag instead` when "badflag" is used.
+This hides "badflag" from help text, and prints `Flag --badflag has been deprecated, please use --good-flag instead` when "badflag" is used.
-**Example #2**: You want to keep a flag name "noshorthandflag" but deprecate its shortname "n".
+**Example #2**: You want to keep a flag name "noshorthandflag" but deprecate its shortname "n".
```go
-// deprecate a flag shorthand by specifying its flag name and a usage message
+// deprecate a flag shorthand by specifying its flag name and a usage message
flags.MarkShorthandDeprecated("noshorthandflag", "please use --noshorthandflag only")
```
-This hides the shortname "n" from help text, and prints `Flag shorthand -n has been deprecated, please use --noshorthandflag only` when the shorthand "n" is used.
+This hides the shortname "n" from help text, and prints `Flag shorthand -n has been deprecated, please use --noshorthandflag only` when the shorthand "n" is used.
-Note that usage message is essential here, and it should not be empty.
+Note that usage message is essential here, and it should not be empty.
+
+## Hidden flags
+It is possible to mark a flag as hidden, meaning it will still function as normal, however will not show up in usage/help text.
+
+**Example**: You have a flag named "secretFlag" that you need for internal use only and don't want it showing up in help text, or for its usage text to be available.
+```go
+// hide a flag by specifying its name
+flags.MarkHidden("secretFlag")
+```
## More info