From d7961941f0ceee4e55062041991de7bbd43b2b57 Mon Sep 17 00:00:00 2001 From: Rick Date: Mon, 2 Oct 2017 14:18:41 +0100 Subject: Altered help tag parsing to reduce the constraints on help text content; old behaviour is retained for backward compatibility --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 3f9223c..18e572d 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,9 @@ Workers: 4 var args struct { Input string `arg:"positional"` Output []string `arg:"positional"` - Verbose bool `arg:"-v,help:verbosity level"` - Dataset string `arg:"help:dataset to use"` - Optimize int `arg:"-O,help:optimization level"` + Verbose bool `arg:"-v" help:"verbosity level"` + Dataset string `help:"dataset to use"` + Optimize int `arg:"-O" help:"optimization level"` } arg.MustParse(&args) ``` @@ -306,7 +306,7 @@ Options: --help, -h display this help and exit ``` -### Documentation +### API Documentation https://godoc.org/github.com/alexflint/go-arg @@ -319,3 +319,7 @@ The shortcomings of the `flag` library that ships in the standard library are we Many third-party argument parsing libraries are geared for writing sophisticated command line interfaces. The excellent `codegangsta/cli` is perfect for working with multiple sub-commands and nested flags, but is probably overkill for a simple script with a handful of flags. The main idea behind `go-arg` is that Go already has an excellent way to describe data structures using Go structs, so there is no need to develop more levels of abstraction on top of this. Instead of one API to specify which arguments your program accepts, and then another API to get the values of those arguments, why not replace both with a single struct? + +### Backward Compatibility Notes + +The tags have changed recently. Earlier versions required the help text to be part of the `arg` tag. This is still supported but is now deprecated. Instead, you should use a separate `help` tag, described above, which removes most of the limits on the text you can write. -- cgit v1.2.3