summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-10-10 10:52:42 +1030
committerAlex Flint <[email protected]>2016-10-10 10:52:42 +1030
commit03900620e2d015e9573ac7a20e71ed091a308ba0 (patch)
tree8545720097c55d27c6b595cedf6be6b350e97403 /README.md
parent12fa37d10d7e48cd451f4da1facc9b4ec8d631fa (diff)
add not on embedding to readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4aa311e..bc761de 100644
--- a/README.md
+++ b/README.md
@@ -188,6 +188,34 @@ $ ./example --version
someprogram 4.3.0
```
+### Embedded structs
+
+The fields of embedded structs are treated just like regular fields:
+
+```go
+
+type DatabaseOptions struct {
+ Host string
+ Username string
+ Password string
+}
+
+type LogOptions struct {
+ LogFile string
+ Verbose bool
+}
+
+func main() {
+ var args struct {
+ DatabaseOptions
+ LogOptions
+ }
+ arg.MustParse(&args)
+}
+```
+
+As usual, any field tagged with `arg:"-"` is ignored.
+
### Custom parsing
You can implement your own argument parser by implementing `encoding.TextUnmarshaler`: