diff options
| author | Alex Flint <[email protected]> | 2016-10-11 09:09:17 +1030 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-10-11 09:09:17 +1030 |
| commit | 7c77c70f8528a7b3310820aeec46d56a5be1ba70 (patch) | |
| tree | 8545720097c55d27c6b595cedf6be6b350e97403 /README.md | |
| parent | e6fdb157e91f007265d9db6bbc7029d18bab4f6b (diff) | |
| parent | 03900620e2d015e9573ac7a20e71ed091a308ba0 (diff) | |
Merge pull request #39 from alexflint/embedded
add support for embedded structs
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`: |
