summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md54
1 files changed, 52 insertions, 2 deletions
diff --git a/README.md b/README.md
index dab2996..f105b17 100644
--- a/README.md
+++ b/README.md
@@ -134,10 +134,10 @@ arg.MustParse(&args)
```shell
$ ./example -h
-Usage: [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] [--help] INPUT [OUTPUT [OUTPUT ...]]
+Usage: [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] [--help] INPUT [OUTPUT [OUTPUT ...]]
Positional arguments:
- INPUT
+ INPUT
OUTPUT
Options:
@@ -180,6 +180,24 @@ var args struct {
arg.MustParse(&args)
```
+#### Ignoring environment variables and/or default values
+
+The values in an existing structure can be kept in-tact by ignoring environment
+variables and/or default values.
+
+```go
+var args struct {
+ Test string `arg:"-t,env:TEST" default:"something"`
+}
+
+p, err := arg.NewParser(arg.Config{
+ IgnoreEnv: true,
+ IgnoreDefault: true,
+}, &args)
+
+err = p.Parse(os.Args)
+```
+
### Arguments with multiple values
```go
var args struct {
@@ -444,6 +462,9 @@ Options:
### Description strings
+A descriptive message can be added at the top of the help text by implementing
+a `Description` function that returns a string.
+
```go
type args struct {
Foo string
@@ -469,6 +490,35 @@ Options:
--help, -h display this help and exit
```
+Similarly an epilogue can be added at the end of the help text by implementing
+the `Epilogue` function.
+
+```go
+type args struct {
+ Foo string
+}
+
+func (args) Epilogue() string {
+ return "For more information visit github.com/alexflint/go-arg"
+}
+
+func main() {
+ var args args
+ arg.MustParse(&args)
+}
+```
+
+```shell
+$ ./example -h
+Usage: example [--foo FOO]
+
+Options:
+ --foo FOO
+ --help, -h display this help and exit
+
+For more information visit github.com/alexflint/go-arg
+```
+
### Subcommands
*Introduced in version 1.1.0*