summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2015-10-31 18:49:20 -0700
committerAlex Flint <[email protected]>2015-10-31 18:49:20 -0700
commit65820885963ded66c34560ac619b323a8bbfc032 (patch)
tree1682016b101133256b10bc894a0e467f08325b6b
parent04e96c0c6b8bb92fba62bcc5a080e7727ad3edfd (diff)
udpate readme
-rw-r--r--README.md20
1 files changed, 9 insertions, 11 deletions
diff --git a/README.md b/README.md
index f3db6c9..88441de 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Argument parsing for Go
-```golang
+```go
import "github.com/alexflint/go-arg"
var args struct {
@@ -8,19 +8,17 @@ var args struct {
Bar bool
}
arg.MustParse(&args)
-fmt.Println(args.Foo)
-fmt.Println(args.Bar)
+fmt.Println(args.Foo, args.Bar)
```
-```bash
+```shell
$ ./example --foo=hello --bar
-hello
-True
+hello True
```
### Default values
-```golang
+```go
var args struct {
Foo string
Bar bool
@@ -31,7 +29,7 @@ arg.MustParse(&args)
### Marking options as required
-```golang
+```go
var args struct {
Foo string `arg:"required"`
Bar bool
@@ -41,7 +39,7 @@ arg.MustParse(&args)
### Positional argument
-```golang
+```go
var args struct {
Input string `arg:"positional"`
Output []string `arg:"positional"`
@@ -59,7 +57,7 @@ Output: [x.out y.out z.out]
```
### Usage strings
-```bash
+```shell
$ ./example -h
usage: [--verbose] [--dataset DATASET] [--optimize OPTIMIZE] [--help] INPUT [OUTPUT [OUTPUT ...]]
@@ -85,7 +83,7 @@ arg.MustParse(&args)
fmt.Printf("Fetching the following IDs from %s: %q", args.Database, args.IDs)
```
-```bash
+```shell
./example -database foo -ids 1 2 3
Fetching the following IDs from foo: [1 2 3]
```