From 60f2612c0c59b979f71241405515e722bf6943f0 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Sun, 1 Nov 2015 13:53:51 -0800 Subject: separate help into WriteUsage and WriteHelp --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1a7377c..b3b5886 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,6 @@ $ ./example --foo=hello --bar hello true ``` -### Default values - -```go -var args struct { - Foo string - Bar bool -} -args.Foo = "default value" -arg.MustParse(&args) -``` - ### Required arguments ```go @@ -40,6 +29,12 @@ var args struct { arg.MustParse(&args) ``` +```shell +$ ./example +usage: example --foo FOO [--bar] +error: --foo is required +``` + ### Positional arguments ```go @@ -79,11 +74,22 @@ positional arguments: output options: ---verbose, -v verbosity level ---dataset DATASET dataset to use ---optimize OPTIMIZE, -O OPTIMIZE - optimization level ---help, -h print this help message + --verbose, -v verbosity level + --dataset DATASET dataset to use + --optimize OPTIMIZE, -O OPTIMIZE + optimization level + --help, -h print this help message +``` + +### Default values + +```go +var args struct { + Foo string + Bar bool +} +args.Foo = "default value" +arg.MustParse(&args) ``` ### Arguments with multiple values -- cgit v1.2.3