Commit 17c290ff authored by Russ Cox's avatar Russ Cox

tweak flag comment

R=r
DELTA=36  (1 added, 0 deleted, 35 changed)
OCL=27484
CL=27522
parent 457b0030
...@@ -3,41 +3,42 @@ ...@@ -3,41 +3,42 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
/* /*
* Flags The flag package implements command-line flag parsing.
*
* Usage: Usage:
* 1) Define flags using flag.String(), Bool(), Int(), etc. Example:
* import flag "flag" 1) Define flags using flag.String(), Bool(), Int(), etc. Example:
* var ip *int = flag.Int("flagname", 1234, "help message for flagname") import flag "flag"
* If you like, you can bind the flag to a variable using the Var() functions. var ip *int = flag.Int("flagname", 1234, "help message for flagname")
* var flagvar int If you like, you can bind the flag to a variable using the Var() functions.
* func init() { var flagvar int
* flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") func init() {
* } flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
* }
* 2) After all flags are defined, call
* flag.Parse() 2) After all flags are defined, call
* to parse the command line into the defined flags. 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. 3) Flags may then be used directly. If you're using the flags themselves,
* print("ip has value ", *ip, "\n"); they are all pointers; if you bind to variables, they're values.
* print("flagvar has value ", flagvar, "\n"); 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(). 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 Command line flag syntax:
* -flag=x -flag
* -flag x -flag=x
* One or two minus signs may be used; they are equivalent. -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 "--". 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. 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 package flag
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment