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


Golang FlagSet.BoolVar方法代碼示例

本文整理匯總了Golang中github.com/tsuru/gnuflag.FlagSet.BoolVar方法的典型用法代碼示例。如果您正苦於以下問題:Golang FlagSet.BoolVar方法的具體用法?Golang FlagSet.BoolVar怎麽用?Golang FlagSet.BoolVar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/tsuru/gnuflag.FlagSet的用法示例。


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

示例1: RegisterLevelDBFlags

func RegisterLevelDBFlags(flags *flag.FlagSet) {
	if !flagsRegistered {
		flagsRegistered = true
		flags.IntVar(&ldbFlags.maxFileHandles, "ldb-max-file-handles", 24, "max number of open file handles")
		flags.BoolVar(&ldbFlags.dumpStats, "ldb-dump-stats", false, "print get/has/put counts on close")
	}
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:7,代碼來源:leveldb_store.go

示例2: handleFlags

func (m *Manager) handleFlags(command Command, name string, args []string) (Command, []string, error) {
	var flagset *gnuflag.FlagSet
	if flagged, ok := command.(FlaggedCommand); ok {
		flagset = flagged.Flags()
	} else {
		flagset = gnuflag.NewFlagSet(name, gnuflag.ExitOnError)
	}
	var helpRequested bool
	flagset.SetOutput(m.stderr)
	if flagset.Lookup("help") == nil {
		flagset.BoolVar(&helpRequested, "help", false, "Display help and exit")
	}
	if flagset.Lookup("h") == nil {
		flagset.BoolVar(&helpRequested, "h", false, "Display help and exit")
	}
	err := flagset.Parse(true, args)
	if err != nil {
		return nil, nil, err
	}
	if helpRequested {
		command = m.Commands["help"]
		args = []string{name}
	} else {
		args = flagset.Args()
	}
	return command, args, nil
}
開發者ID:botvs,項目名稱:tsuru,代碼行數:27,代碼來源:cmd.go

示例3: flags

func (c *dockerCmd) flags(fs *gnuflag.FlagSet) {
	c.addMany(fs, &c.raw, "Add raw parameter to node container api call", "r", "raw")
	c.addMany(fs, cmd.StringSliceFlagWrapper{Dst: &c.config.Config.Env}, "Set environment variables", "e", "env")
	c.addMany(fs, cmd.StringSliceFlagWrapper{Dst: &c.config.HostConfig.Binds}, "Bind mount a volume", "v", "volume")
	c.addMany(fs, cmd.MapFlagWrapper{Dst: &c.config.HostConfig.LogConfig.Config}, "Log driver options", "log-opt")
	c.addMany(fs, &c.ports, "Publish a container's port(s) to the host", "p", "publish")
	fs.BoolVar(&c.config.HostConfig.Privileged, "privileged", false, "Give extended privileges to this container")
	fs.StringVar(&c.config.Config.Image, "image", "", "Image that will be used")
	fs.StringVar(&c.config.HostConfig.RestartPolicy.Name, "restart", "", "Restart policy to apply when a container exits")
	fs.StringVar(&c.config.HostConfig.NetworkMode, "net", "", "Connect a container to a network")
	fs.StringVar(&c.config.HostConfig.LogConfig.Type, "log-driver", "", "Logging driver for container")
}
開發者ID:tsuru,項目名稱:tsuru,代碼行數:12,代碼來源:cmd.go

示例4: RegisterOutputpagerFlags

func RegisterOutputpagerFlags(flags *flag.FlagSet) {
	if !flagsRegistered {
		flagsRegistered = true
		flags.BoolVar(&noPager, "no-pager", false, "suppress paging functionality")
	}
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:6,代碼來源:page_output.go


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