1 // Package arg parses command line arguments using the fields from a struct.
2 //
3 // For example,
4 //
5 // var args struct {
6 // Iter int
7 // Debug bool
8 // }
9 // arg.MustParse(&args)
10 //
11 // defines two command line arguments, which can be set using any of
12 //
13 // ./example --iter=1 --debug // debug is a boolean flag so its value is set to true
14 // ./example -iter 1 // debug defaults to its zero value (false)
15 // ./example --debug=true // iter defaults to its zero value (zero)
16 //
17 // The fastest way to see how to use go-arg is to read the examples below.
18 //
19 // Fields can be bool, string, any float type, or any signed or unsigned integer type.
20 // They can also be slices of any of the above, or slices of pointers to any of the above.
21 //
22 // Tags can be specified using the `arg` and `help` tag names:
23 //
24 // var args struct {
25 // Input string `arg:"positional"`
26 // Log string `arg:"positional,required"`
27 // Debug bool `arg:"-d" help:"turn on debug mode"`
28 // RealMode bool `arg:"--real"
29 // Wr io.Writer `arg:"-"`
30 // }
31 //
32 // Any tag string that starts with a single hyphen is the short form for an argument
33 // (e.g. `./example -d`), and any tag string that starts with two hyphens is the long
34 // form for the argument (instead of the field name).
35 //
36 // Other valid tag strings are `positional`, `required`, and `hidden`. Using `hidden` will
37 // exclude the field from help text and usage messages.
38 //
39 // Fields can be excluded from processing with `arg:"-"`.
40 package arg
41