From b96b4adfe5992b2ea805d2d3ee4d86e35eea3bd4 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Wed, 5 Oct 2022 16:33:43 +0200 Subject: [PATCH] doc: shadow described --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0384678..6473bca 100644 --- a/README.md +++ b/README.md @@ -65,9 +65,9 @@ The following tags are supported: | `required` | Value | Flag is required. | | `command` | Command | Flag is a command. | | `call` | Command | Function to call when the command is used. | +| `shadow` | Value | Copy the value to the shadow structure. | | `ignore` | -/- | Property is ignored. | - ### Callbacks The functions are called up with a receiver. The receiver is the @@ -143,6 +143,30 @@ The function `Execute()` executes the command. See the section setting.Execute() ``` +### Shadow + +The shadow structure is used to copy the values of the flags to the +shadow structure. The shadow structure is set using the `SetShadow()` +and configured using the tag `shadow`. + +```go +type Shadow struct { + Verbose bool + Serve struct { + Host string + Port int + } +} + +func main() { + setting := New(os.Args[0], Definition{}) + setting.SetShadow(Shadow{}) + setting.Parse(os.Args[1:]) + setting.Execute() + fmt.Printf("Shadow: %+v", setting.GetShadow()) +} +``` + ## Contributing Merge requests are welcome. For major changes, please open an issue first to discuss what -- GitLab