diff options
| author | Alex Flint <[email protected]> | 2016-10-10 10:52:42 +1030 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2016-10-10 10:52:42 +1030 |
| commit | 03900620e2d015e9573ac7a20e71ed091a308ba0 (patch) | |
| tree | 8545720097c55d27c6b595cedf6be6b350e97403 /README.md | |
| parent | 12fa37d10d7e48cd451f4da1facc9b4ec8d631fa (diff) | |
add not on embedding to readme
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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`: |
