summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-10-11 09:09:17 +1030
committerGitHub <[email protected]>2016-10-11 09:09:17 +1030
commit7c77c70f8528a7b3310820aeec46d56a5be1ba70 (patch)
tree8545720097c55d27c6b595cedf6be6b350e97403 /README.md
parente6fdb157e91f007265d9db6bbc7029d18bab4f6b (diff)
parent03900620e2d015e9573ac7a20e71ed091a308ba0 (diff)
Merge pull request #39 from alexflint/embedded
add support for embedded structs
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`: