瀏覽代碼

Merge pull request #4672 from vieux/update_godoc_mflags

update godoc and add MAINTAINERS for mflags
unclejack 11 年之前
父節點
當前提交
555c1ef670
共有 2 個文件被更改,包括 14 次插入1 次删除
  1. 1 0
      pkg/mflag/MAINTAINERS
  2. 13 1
      pkg/mflag/flag.go

+ 1 - 0
pkg/mflag/MAINTAINERS

@@ -0,0 +1 @@
+Victor Vieux <victor.vieux@docker.com> (@vieux)

+ 13 - 1
pkg/mflag/flag.go

@@ -10,7 +10,7 @@
 	Define flags using flag.String(), Bool(), Int(), etc.
 	Define flags using flag.String(), Bool(), Int(), etc.
 
 
 	This declares an integer flag, -f or --flagname, stored in the pointer ip, with type *int.
 	This declares an integer flag, -f or --flagname, stored in the pointer ip, with type *int.
-		import "flag"
+		import "flag /github.com/dotcloud/docker/pkg/mflag"
 		var ip = flag.Int([]string{"f", "-flagname"}, 1234, "help message for flagname")
 		var ip = flag.Int([]string{"f", "-flagname"}, 1234, "help message for flagname")
 	If you like, you can bind the flag to a variable using the Var() functions.
 	If you like, you can bind the flag to a variable using the Var() functions.
 		var flagvar int
 		var flagvar int
@@ -23,6 +23,18 @@
 		flag.Var(&flagVal, []string{"name"}, "help message for flagname")
 		flag.Var(&flagVal, []string{"name"}, "help message for flagname")
 	For such flags, the default value is just the initial value of the variable.
 	For such flags, the default value is just the initial value of the variable.
 
 
+	You can also add "deprecated" flags, they are still usable, bur are not shown
+	in the usage and will display a warning when you try to use them:
+		var ip = flag.Int([]string{"f", "#flagname", "-flagname"}, 1234, "help message for flagname")
+	this will display: `Warning: '-flagname' is deprecated, it will be replaced by '--flagname' soon. See usage.` and
+		var ip = flag.Int([]string{"f", "#flagname"}, 1234, "help message for flagname")
+	will display: `Warning: '-t' is deprecated, it will be removed soon. See usage.`
+
+	You can also group one letter flags, bif you declare
+		var v = flag.Bool([]string{"v", "-verbose"}, false, "help message for verbose")
+		var s = flag.Bool([]string{"s", "-slow"}, false, "help message for slow")
+	you will be able to use the -vs or -sv
+
 	After all flags are defined, call
 	After all flags are defined, call
 		flag.Parse()
 		flag.Parse()
 	to parse the command line into the defined flags.
 	to parse the command line into the defined flags.