Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
17c290ff
Commit
17c290ff
authored
Apr 16, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak flag comment
R=r DELTA=36 (1 added, 0 deleted, 35 changed) OCL=27484 CL=27522
parent
457b0030
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
35 deletions
+36
-35
flag.go
src/lib/flag.go
+36
-35
No files found.
src/lib/flag.go
View file @
17c290ff
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment