add to readme
This commit is contained in:
parent
c453aa1a28
commit
f882700b72
22
README.md
22
README.md
|
@ -166,6 +166,28 @@ usage: samples [--foo FOO] [--bar BAR]
|
||||||
error: you must provide one of --foo and --bar
|
error: you must provide one of --foo and --bar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Version strings
|
||||||
|
|
||||||
|
```go
|
||||||
|
type args struct {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
func (args) Version() string {
|
||||||
|
return "someprogram 4.3.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var args args
|
||||||
|
arg.MustParse(&args)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ ./example --version
|
||||||
|
someprogram 4.3.0
|
||||||
|
```
|
||||||
|
|
||||||
### Custom parsing
|
### Custom parsing
|
||||||
|
|
||||||
You can implement your own argument parser by implementing `encoding.TextUnmarshaler`:
|
You can implement your own argument parser by implementing `encoding.TextUnmarshaler`:
|
||||||
|
|
Loading…
Reference in New Issue