diff options
| author | Russ Cox <rsc@golang.org> | 2009-04-15 18:39:35 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-04-15 18:39:35 -0700 |
| commit | 17c290ffb9a14061321eb570a8d3e3a93d8ca2c9 (patch) | |
| tree | 05f15f75178fc96a14f284103a06a51c9aa9a22c /src/lib | |
| parent | 457b0030f70e7179cbfb1935461071e8129ed75e (diff) | |
| download | go-17c290ffb9a14061321eb570a8d3e3a93d8ca2c9.tar.xz | |
tweak flag comment
R=r
DELTA=36 (1 added, 0 deleted, 35 changed)
OCL=27484
CL=27522
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/flag.go | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/src/lib/flag.go b/src/lib/flag.go index d8830c9dc4..a63bdf6b05 100644 --- a/src/lib/flag.go +++ b/src/lib/flag.go @@ -3,41 +3,42 @@ // license that can be found in the LICENSE file. /* - * Flags - * - * Usage: - * 1) Define flags using flag.String(), Bool(), Int(), etc. Example: - * import flag "flag" - * var ip *int = flag.Int("flagname", 1234, "help message for flagname") - * If you like, you can bind the flag to a variable using the Var() functions. - * var flagvar int - * func init() { - * flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") - * } - * - * 2) After all flags are defined, call - * flag.Parse() - * to parse the command line into the defined flags. - * - * 3) Flags may then be used directly. If you're using the flags themselves, - * they are all pointers; if you bind to variables, they're values. - * print("ip has value ", *ip, "\n"); - * print("flagvar has value ", flagvar, "\n"); - * - * 4) After parsing, flag.Arg(i) is the i'th argument after the flags. - * Args are indexed from 0 up to flag.NArg(). - * - * Command line flag syntax: - * -flag - * -flag=x - * -flag x - * One or two minus signs may be used; they are equivalent. - * - * Flag parsing stops just before the first non-flag argument - * ("-" is a non-flag argument) or after the terminator "--". - * - * Integer flags accept 1234, 0664, 0x1234 and may be negative. - * Boolean flags may be 1, 0, t, f, true, false, TRUE, FALSE, True, False. + The flag package implements command-line flag parsing. + + Usage: + + 1) Define flags using flag.String(), Bool(), Int(), etc. Example: + import flag "flag" + var ip *int = flag.Int("flagname", 1234, "help message for flagname") + If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int + func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + } + + 2) After all flags are defined, call + flag.Parse() + to parse the command line into the defined flags. + + 3) Flags may then be used directly. If you're using the flags themselves, + they are all pointers; if you bind to variables, they're values. + print("ip has value ", *ip, "\n"); + print("flagvar has value ", flagvar, "\n"); + + 4) After parsing, flag.Arg(i) is the i'th argument after the flags. + Args are indexed from 0 up to flag.NArg(). + + Command line flag syntax: + -flag + -flag=x + -flag x + One or two minus signs may be used; they are equivalent. + + Flag parsing stops just before the first non-flag argument + ("-" is a non-flag argument) or after the terminator "--". + + Integer flags accept 1234, 0664, 0x1234 and may be negative. + Boolean flags may be 1, 0, t, f, true, false, TRUE, FALSE, True, False. */ package flag |
