本文整理汇总了Golang中github.com/tsuru/gnuflag.NewFlagSet函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFlagSet函数的具体用法?Golang NewFlagSet怎么用?Golang NewFlagSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFlagSet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMergeFlagSet
func (s *S) TestMergeFlagSet(c *check.C) {
var x, y bool
fs1 := gnuflag.NewFlagSet("x", gnuflag.ExitOnError)
fs1.BoolVar(&x, "x", false, "Something")
fs2 := gnuflag.NewFlagSet("y", gnuflag.ExitOnError)
fs2.BoolVar(&y, "y", false, "Something")
ret := MergeFlagSet(fs1, fs2)
c.Assert(ret, check.Equals, fs1)
fs1.Parse(true, []string{"-x", "-y"})
c.Assert(x, check.Equals, true)
c.Assert(y, check.Equals, true)
}
示例2: Flags
func (a *addNodeToSchedulerCmd) Flags() *gnuflag.FlagSet {
if a.fs == nil {
a.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
a.fs.BoolVar(&a.register, "register", false, "Register an already created node")
}
return a.fs
}
示例3: Flags
func (f *fakeCommand) Flags() *gnuflag.FlagSet {
if f.fs == nil {
f.fs = gnuflag.NewFlagSet("fakeCommand", gnuflag.ExitOnError)
f.fs.StringVar(&f.name, "name", "", "your name")
}
return f.fs
}
示例4: Flags
func (c *NodeContainerList) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("flags", gnuflag.ExitOnError)
c.fs.BoolVar(&c.namesOnly, "q", false, "Show only names of existing node containers.")
}
return c.fs
}
示例5: Flags
func (a *addNodeToSchedulerCmd) Flags() *gnuflag.FlagSet {
if a.fs == nil {
a.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
a.fs.BoolVar(&a.register, "register", false, "Registers an existing docker endpoint, the IaaS won't be called.")
}
return a.fs
}
示例6: 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
}
示例7: Flags
func (c *keyList) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("key-list", gnuflag.ExitOnError)
c.fs.BoolVar(&c.notrunc, "n", false, "disable truncation of key content")
c.fs.BoolVar(&c.notrunc, "no-truncate", false, "disable truncation of key content")
}
return c.fs
}
示例8: Flags
func (s *appSwap) Flags() *gnuflag.FlagSet {
if s.fs == nil {
s.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
s.fs.BoolVar(&s.force, "force", false, "Force Swap among apps with different number of units or different platform.")
s.fs.BoolVar(&s.force, "f", false, "Force Swap among apps with different number of units or different platform.")
}
return s.fs
}
示例9: Flags
func (c *ListHealingHistoryCmd) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
c.fs.BoolVar(&c.nodeOnly, "node", false, "List only healing process started for nodes")
c.fs.BoolVar(&c.containerOnly, "container", false, "List only healing process started for containers")
}
return c.fs
}
示例10: Flags
func (cmd *GuessingCommand) Flags() *gnuflag.FlagSet {
if cmd.fs == nil {
cmd.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
cmd.fs.StringVar(&cmd.appName, "app", "", "The name of the app.")
cmd.fs.StringVar(&cmd.appName, "a", "", "The name of the app.")
}
return cmd.fs
}
示例11: Flags
func (c *CommandWithFlags) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
c.fs.IntVar(&c.age, "age", 0, "your age")
c.fs.IntVar(&c.age, "a", 0, "your age")
}
return c.fs
}
示例12: Flags
func (cmd *ConfirmationCommand) Flags() *gnuflag.FlagSet {
if cmd.fs == nil {
cmd.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
cmd.fs.BoolVar(&cmd.yes, "y", false, "Don't ask for confirmation.")
cmd.fs.BoolVar(&cmd.yes, "assume-yes", false, "Don't ask for confirmation.")
}
return cmd.fs
}
示例13: Flags
func (t *targetAdd) Flags() *gnuflag.FlagSet {
if t.fs == nil {
t.fs = gnuflag.NewFlagSet("target-add", gnuflag.ExitOnError)
t.fs.BoolVar(&t.set, "set-current", false, "Add and define the target as the current target")
t.fs.BoolVar(&t.set, "s", false, "Add and define the target as the current target")
}
return t.fs
}
示例14: Flags
func (c *regenerateAPIToken) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
c.fs.StringVar(&c.user, "user", "", "Generates a new API token for the given user email")
c.fs.StringVar(&c.user, "u", "", "Generates a new API token for the given user email")
}
return c.fs
}
示例15: Flags
func (c *planList) Flags() *gnuflag.FlagSet {
if c.fs == nil {
c.fs = gnuflag.NewFlagSet("plan-List", gnuflag.ExitOnError)
bytes := "bytesized units for memory and swap."
c.fs.BoolVar(&c.bytes, "bytes", false, bytes)
c.fs.BoolVar(&c.bytes, "b", false, bytes)
}
return c.fs
}