當前位置: 首頁>>代碼示例>>Golang>>正文


Golang go-commander.Commander類代碼示例

本文整理匯總了Golang中code/google/com/p/go-commander.Commander的典型用法代碼示例。如果您正苦於以下問題:Golang Commander類的具體用法?Golang Commander怎麽用?Golang Commander使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Commander類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	c := commander.Commander{
		Name: "cockroach",
		Commands: []*commander.Command{
			server.CmdInit,
			server.CmdGetZone,
			server.CmdLsZones,
			server.CmdRmZone,
			server.CmdSetZone,
			server.CmdStart,
		},
	}

	if err := c.Run(os.Args[1:]); err != nil {
		os.Exit(1)
	}
}
開發者ID:Zemnmez,項目名稱:cockroach,代碼行數:17,代碼來源:main.go

示例2: main

func main() {
	defer glog.Flush()

	c := commander.Commander{
		Name: "ezgliding",
		Commands: []*commander.Command{
			cli.CmdAirfieldGet,
			cli.CmdAirfieldPut,
			cli.CmdAirspaceGet,
			cli.CmdFlightGet,
			cli.CmdWaypointGet,
			cli.CmdWaypointPut,
			cli.CmdWeb,
		},
	}

	if len(os.Args) == 1 {
		os.Args = append(os.Args, "help")
	}
	if err := c.Run(os.Args[1:]); err != nil {
		glog.Errorf("Failed running command %q: %v", os.Args[1:], err)
		exit(-1)
	}
}
開發者ID:rochaporto,項目名稱:ezgliding,代碼行數:24,代碼來源:main.go

示例3: main

func main() {
	// Instruct Go to use all CPU cores.
	// TODO(spencer): this may be excessive and result in worse
	// performance. We should keep an eye on this as we move to
	// production workloads.
	numCPU := runtime.NumCPU()
	runtime.GOMAXPROCS(numCPU)
	rand.Seed(util.NewPseudoSeed())
	log.V(1).Infof("running using %d processor cores", numCPU)

	c := commander.Commander{
		Name: "cockroach",
		Commands: []*commander.Command{
			cli.CmdInit,
			cli.CmdGetZone,
			cli.CmdLsZones,
			cli.CmdRmZone,
			cli.CmdSetZone,
			cli.CmdStart,
			{
				UsageLine: "listparams",
				Short:     "list all available parameters and their default values",
				Long: `
List all available parameters and their default values.
Note that parameter parsing stops after the first non-
option after the command name. Hence, the options need
to precede any additional arguments,

  cockroach <command> [options] [arguments].`,
				Run: func(cmd *commander.Command, args []string) {
					flag.CommandLine.PrintDefaults()
				},
			},
			{
				UsageLine: "version",
				Short:     "output version information",
				Long: `
Output build version information.
`,
				Run: func(cmd *commander.Command, args []string) {
					info := util.GetBuildInfo()
					w := &tabwriter.Writer{}
					w.Init(os.Stdout, 2, 1, 2, ' ', 0)
					fmt.Fprintf(w, "Build Vers:  %s\n", info.Vers)
					fmt.Fprintf(w, "Build Tag:   %s\n", info.Tag)
					fmt.Fprintf(w, "Build Time:  %s\n", info.Time)
					fmt.Fprintf(w, "Build Deps:\n\t%s\n",
						strings.Replace(strings.Replace(info.Deps, " ", "\n\t", -1), ":", "\t", -1))
					w.Flush()
				},
			},
		},
	}

	cli.InitFlags(cli.Context)

	if len(os.Args) == 1 {
		os.Args = append(os.Args, "help")
	}
	if err := c.Run(os.Args[1:]); err != nil {
		log.Fatalf("Failed running command %q: %v\n", os.Args[1:], err)
	}
}
開發者ID:josephwinston,項目名稱:cockroach,代碼行數:63,代碼來源:main.go


注:本文中的code/google/com/p/go-commander.Commander類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。