예제 #1
0
파일: example.go 프로젝트: rjeczalik/docker
func init() {
	flag.BoolVar(&b, []string{"b"}, false, "a simple bool")
	flag.IntVar(&i, []string{"#integer", "-integer"}, -1, "a simple integer")
	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()
}
예제 #2
0
func init() {
	flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
	flag.BoolVar(&b, []string{"b", "#bal", "#bol", "-bal"}, false, "a simple bool")
	flag.BoolVar(&b, []string{"g", "#gil"}, false, "a simple bool")
	flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
	flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
	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.StringVar(&str, []string{"mode"}, "mode1", "set the mode\nmode1: use the mode1\nmode2: use the mode2\nmode3: use the mode3")
	flag.Parse()
}
예제 #3
0
파일: volt.go 프로젝트: ruo91/volt
func init() {
	flag.IntVar(&port, []string{"p", "-port"}, 8080, "Port to listen on for the API")
	flag.StringVar(&master, []string{"m", "-master"}, "localhost:5050", "Master to connect to")
	flag.BoolVar(&debug, []string{"D", "-debug"}, false, "")
	flag.StringVar(&user, []string{"u", "-user"}, "root", "User to execute tasks as")
	flag.StringVar(&ip, []string{"-ip"}, "", "IP address to listen on [default: autodetect]")

	flag.Parse()
}
예제 #4
0
func parseflg() {
	flag.BoolVar(&show_version, []string{"v", "-version"}, false, "show version.")
	flag.BoolVar(&show_usage, []string{"h", "-help"}, false, "show this usage.")
	flag.BoolVar(&tsv_mode, []string{"t", "-tsv"}, false, "Output with TSV format")
	flag.Parse()
}
예제 #5
0
파일: hecate.go 프로젝트: jbdalido/hecate
func main() {

	// setup command line arguments
	var (
		kubernetes bool
		mesos      bool
		scheduler  string
		host       string
		app        string
		version    bool
		discover   bool
	)

	// Override flag with docker mflag
	// TODO :
	//      - need to simplify flags, there is way too much of them
	flag.StringVar(&app, []string{"a", "-app"}, "", "App id used by your scheduler")
	flag.StringVar(&host, []string{"h", "-host"}, "", "Host to use with the scheduler")

	flag.BoolVar(&kubernetes, []string{"k", "-kubernetes"}, false, "Connect to Kubernetes endpoint")
	flag.BoolVar(&mesos, []string{"m", "-mesos"}, false, "Connect to Mesos endpoint")
	flag.StringVar(&scheduler, []string{"s", "-scheduler"}, "mesos", "Literral adapter")

	flag.BoolVar(&discover, []string{"d", "-discover"}, false, "Discover all apps and endpoints")
	flag.BoolVar(&version, []string{"v", "-version"}, false, "Show Version")

	log.SetPrefix("[WIP]")
	log.SetFlags(0)
	flag.Parse()

	if version {
		showVersion()
		os.Exit(0)
	}

	if !discover && app == "" {
		log.Fatal("Application can't be null")
	}

	if host == "" {
		log.Fatal("Host can't be null")
	}

	if kubernetes {
		scheduler = "kubernetes"
	}

	client, err := api.NewClient(scheduler, host)
	if err != nil {
		log.Fatalf("Error %s", err)
	}

	// TODO
	// - need to delegate the String() function
	//   to the client
	// - need to handle nginx conf via template
	//   or via etcd to be purge via confd
	//   or find another way
	if app != "" && !discover {
		response, err := client.Discover(app)
		if err != nil {
			log.Fatalf("%s", err)
		}
		r, _ := json.Marshal(response)
		fmt.Printf("%s\n", r)
	}

	if discover {
		response, err := client.DiscoverAll()
		if err != nil {
			log.Fatalf("%s", err)
		}
		r, _ := json.Marshal(response)
		fmt.Printf("%s\n", r)
	}

}