2013-12-23 19:43:54 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-01-27 23:25:14 +00:00
|
|
|
flag "github.com/dotcloud/docker/pkg/mflag"
|
2013-12-23 19:43:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2014-01-31 19:33:48 +00:00
|
|
|
i int
|
|
|
|
str string
|
|
|
|
b, b2, h bool
|
2013-12-23 19:43:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2014-03-05 19:27:39 +00:00
|
|
|
flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
|
2013-12-23 19:43:54 +00:00
|
|
|
flag.BoolVar(&b, []string{"b"}, false, "a simple bool")
|
2014-03-05 19:45:57 +00:00
|
|
|
flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
|
|
|
|
flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
|
2013-12-23 19:43:54 +00:00
|
|
|
flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
|
|
|
|
flag.BoolVar(&h, []string{"h", "#help", "-help"}, false, "display the help")
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
func main() {
|
|
|
|
if h {
|
|
|
|
flag.PrintDefaults()
|
|
|
|
}
|
2014-01-31 19:33:48 +00:00
|
|
|
fmt.Printf("s/#hidden/-string: %s\n", str)
|
|
|
|
fmt.Printf("b: %b\n", b)
|
|
|
|
fmt.Printf("-bool: %b\n", b2)
|
|
|
|
fmt.Printf("s/#hidden/-string(via lookup): %s\n", flag.Lookup("s").Value.String())
|
2014-02-19 00:24:32 +00:00
|
|
|
fmt.Printf("ARGS: %v\n", flag.Args())
|
2013-12-23 19:43:54 +00:00
|
|
|
}
|