From 03900620e2d015e9573ac7a20e71ed091a308ba0 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Mon, 10 Oct 2016 10:52:42 +1030 Subject: [PATCH] add not on embedding to readme --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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`: