示例#1
0
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
0
文件: cmd.go 项目: Endika/tsuru
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
0
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
0
文件: cmd.go 项目: tsuru/tsuru
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
0
文件: cmd.go 项目: pedrosnk/tsuru
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
0
文件: cmd.go 项目: botvs/tsuru
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
0
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
0
func (c *keyAdd) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("key-add", gnuflag.ExitOnError)
		c.fs.BoolVar(&c.force, "force", false, "Force overriding the key if it already exists")
		c.fs.BoolVar(&c.force, "f", false, "Force overriding the key if it already exists")
	}
	return c.fs
}
示例#9
0
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
}
示例#10
0
文件: cmd.go 项目: tsuru/tsuru
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
}
示例#11
0
文件: guess.go 项目: zhenruyan/tsuru
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
}
示例#12
0
文件: cmd.go 项目: tsuru/tsuru
func (c *listAutoScaleHistoryCmd) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
		c.fs.IntVar(&c.page, "page", 1, "Current page")
		c.fs.IntVar(&c.page, "p", 1, "Current page")
	}
	return c.fs
}
示例#13
0
文件: cmd.go 项目: Endika/tsuru
func (a *updateNodeToSchedulerCmd) Flags() *gnuflag.FlagSet {
	if a.fs == nil {
		a.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
		a.fs.BoolVar(&a.disabled, "disable", false, "Disable node in scheduler.")
		a.fs.BoolVar(&a.enabled, "enable", false, "Enable node in scheduler.")
	}
	return a.fs
}
示例#14
0
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
}
示例#15
0
func (c *HelpCommandWithFlags) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
		c.fs.BoolVar(&c.h, "help", false, "help?")
		c.fs.BoolVar(&c.h, "h", false, "help?")
	}
	return c.fs
}
示例#16
0
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
}
示例#17
0
文件: target.go 项目: tsuru/tsuru
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
}
示例#18
0
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
}
示例#19
0
文件: cmd.go 项目: Endika/tsuru
func (c *listNodesInTheSchedulerCmd) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
		filter := "Filter by metadata value"
		c.fs.Var(&c.filter, "filter", filter)
		c.fs.Var(&c.filter, "f", filter)
	}
	return c.fs
}
示例#20
0
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
}
示例#21
0
文件: api.go 项目: zhenruyan/tsuru
func (c *apiCmd) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("api", gnuflag.ExitOnError)
		c.fs.BoolVar(&c.dry, "dry", false, "dry-run: does not start the server (for testing purpose)")
		c.fs.BoolVar(&c.dry, "d", false, "dry-run: does not start the server (for testing purpose)")
		c.fs.BoolVar(&c.checkOnly, "t", false, "check only config: test your tsuru.conf file before starts.")
	}
	return c.fs
}
示例#22
0
文件: cmd.go 项目: botvs/tsuru
func (c *EnvSetCmd) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
		desc := "Pool name where set variables will apply"
		c.fs.StringVar(&c.pool, "pool", "", desc)
		c.fs.StringVar(&c.pool, "p", "", desc)
	}
	return c.fs
}
示例#23
0
func (c *serviceUpdate) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("service-update", gnuflag.ExitOnError)
		descriptionMessage := "service instance description"
		c.fs.StringVar(&c.description, "description", "", descriptionMessage)
		c.fs.StringVar(&c.description, "d", "", descriptionMessage)
	}
	return c.fs
}
示例#24
0
func (c *permissionList) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("plan-List", gnuflag.ExitOnError)
		tree := "Show permissions in tree format."
		c.fs.BoolVar(&c.tree, "tree", false, tree)
		c.fs.BoolVar(&c.tree, "t", false, tree)
	}
	return c.fs
}
示例#25
0
func (c *serviceRemove) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("service-remove", gnuflag.ExitOnError)
		c.fs.BoolVar(&c.yes, "assume-yes", false, "Don't ask for confirmation, just remove the service.")
		c.fs.BoolVar(&c.yes, "y", false, "Don't ask for confirmation, just remove the service.")
		c.fs.BoolVar(&c.yesUnbind, "unbind", false, "Don't ask for confirmation, just remove all applications bound.")
		c.fs.BoolVar(&c.yesUnbind, "u", false, "Don't ask for confirmation, just remove all applications bound.")
	}
	return c.fs
}
示例#26
0
func (c *listUsers) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("", gnuflag.ExitOnError)
		c.fs.StringVar(&c.userEmail, "user", "", "Filter user by user email")
		c.fs.StringVar(&c.userEmail, "u", "", "Filter user by user email")
		c.fs.StringVar(&c.role, "r", "", "Filter user by role")
		c.fs.StringVar(&c.role, "role", "", "Filter user by role")
	}
	return c.fs
}
示例#27
0
文件: cmd.go 项目: tsuru/tsuru
func (c *NodeContainerUpdate) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("flags", gnuflag.ExitOnError)
		c.dockerCmd.flags(c.fs)
		msg := "Pool to update container config. If empty it'll be a default entry to all pools."
		c.fs.StringVar(&c.pool, "o", "", msg)
		c.fs.StringVar(&c.pool, "pool", "", msg)
	}
	return c.fs
}
示例#28
0
func setupLogFlags() *flag.FlagSet {
	logFlagSet := flag.NewFlagSet("log", flag.ExitOnError)
	logFlagSet.IntVar(&color, "color", -1, "value of 1 forces color on, 2 forces color off")
	logFlagSet.IntVar(&maxLines, "max-lines", 10, "max number of lines to show per commit (-1 for all lines)")
	logFlagSet.IntVar(&maxCommits, "n", 0, "max number of commits to display (0 for all commits)")
	logFlagSet.BoolVar(&oneline, "oneline", false, "show a summary of each commit on a single line")
	logFlagSet.BoolVar(&showGraph, "graph", false, "show ascii-based commit hierarcy on left side of output")
	logFlagSet.BoolVar(&showValue, "show-value", false, "show commit value rather than diff information -- this is temporary")
	outputpager.RegisterOutputpagerFlags(logFlagSet)
	return logFlagSet
}
示例#29
0
文件: cmd_test.go 项目: botvs/tsuru
func (c *CommandWithFlags) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		c.fs = gnuflag.NewFlagSet("with-flags", gnuflag.ContinueOnError)
		desc := "your age"
		if c.multi == true {
			desc = "velvet darkness\nthey fear"
		}
		c.fs.IntVar(&c.age, "age", 0, desc)
		c.fs.IntVar(&c.age, "a", 0, desc)
	}
	return c.fs
}
示例#30
0
func (c *tsurudCommand) Flags() *gnuflag.FlagSet {
	if c.fs == nil {
		if f, ok := c.Command.(cmd.FlaggedCommand); ok {
			c.fs = f.Flags()
		} else {
			c.fs = gnuflag.NewFlagSet("tsurud", gnuflag.ExitOnError)
		}
		c.fs.Var(&c.file, "config", "Path to configuration file (default to /etc/tsuru/tsuru.conf)")
		c.fs.Var(&c.file, "c", "Path to configuration file (default to /etc/tsuru/tsuru.conf)")
	}
	return c.fs
}