From 65820885963ded66c34560ac619b323a8bbfc032 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Sat, 31 Oct 2015 18:49:20 -0700 Subject: [PATCH] udpate readme --- README.md | 20 +++++++++----------- 1 file 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] ```