本文整理汇总了Golang中launchpad/net/gnuflag.FlagSet.BoolVar方法的典型用法代码示例。如果您正苦于以下问题:Golang FlagSet.BoolVar方法的具体用法?Golang FlagSet.BoolVar怎么用?Golang FlagSet.BoolVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gnuflag.FlagSet
的用法示例。
在下文中一共展示了FlagSet.BoolVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: SetFlags
func (c *toolsMetadataCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&c.metadataDir, "d", "", "local directory in which to store metadata")
// If no stream is specified, we'll generate metadata for the legacy tools location.
f.StringVar(&c.stream, "stream", "", "simplestreams stream for which to generate the metadata")
f.BoolVar(&c.clean, "clean", false, "remove any existing metadata for the specified stream before generating new metadata")
f.BoolVar(&c.public, "public", false, "tools are for a public cloud, so generate mirrors information")
}
示例3: SetFlags
func (c *RunCommand) SetFlags(f *gnuflag.FlagSet) {
f.BoolVar(&c.noContext, "no-context", false, "do not run the command in a unit context")
f.StringVar(&c.relationId, "r", "", "run the commands for a specific relation context on a unit")
f.StringVar(&c.relationId, "relation", "", "")
f.StringVar(&c.remoteUnitName, "remote-unit", "", "run the commands for a specific remote unit in a relation context on a unit")
f.BoolVar(&c.forceRemoteUnit, "force-remote-unit", false, "run the commands for a specific relation context, bypassing the remote unit check")
}
示例4: SetFlags
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
c.EnvCommandBase.SetFlags(f)
f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set environment constraints")
f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping")
f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied comma-separated series list")
f.StringVar(&c.Source, "source", "", "local path to use as tools source")
}
示例5: SetFlags
func (c *UpgradeJujuCommand) SetFlags(f *gnuflag.FlagSet) {
c.EnvCommandBase.SetFlags(f)
f.StringVar(&c.vers, "version", "", "upgrade to specific version")
f.BoolVar(&c.Development, "dev", false, "allow development versions to be chosen")
f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools")
f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied comma-separated series list")
}
示例6: SetFlags
func (c *UpgradeCharmCommand) SetFlags(f *gnuflag.FlagSet) {
c.EnvCommandBase.SetFlags(f)
f.BoolVar(&c.Force, "force", false, "upgrade all units immediately, even if in error state")
f.StringVar(&c.RepoPath, "repository", os.Getenv("JUJU_REPOSITORY"), "local charm repository path")
f.StringVar(&c.SwitchURL, "switch", "", "crossgrade to a different charm")
f.IntVar(&c.Revision, "revision", -1, "explicit revision of current charm")
}
示例7: SetFlags
// SetFlags handles known option flags.
func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) {
f.Var(constraints.ConstraintsValue{Target: &c.constraints},
"constraints", "set environment constraints")
f.BoolVar(&c.bootstrap, "b", false, "bootstrap a new state machine")
f.StringVar(&c.filename, "file", "", "provide a file to be used as the backup.")
f.StringVar(&c.backupId, "id", "", "provide the name of the backup to be restored.")
}
示例8: SetFlags
// SetFlags adds the flags for this command to the passed gnuflag.FlagSet.
func (u *UpgradeMongoCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&u.machineTag, "machinetag", "machine-0", "unique tag identifier for machine to be upgraded")
f.StringVar(&u.series, "series", "", "series for the machine")
f.StringVar(&u.configFilePath, "configfile", "", "path to the config file")
f.StringVar(&u.members, "members", "", "a comma separated list of replicaset member ips")
f.BoolVar(&u.rollback, "rollback", false, "rollback a previous attempt at upgrading that was cut in the process")
f.BoolVar(&u.slave, "slave", false, "this is a slave machine in a replicaset")
}
示例9: SetFlags
func (c *upgradeJujuCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&c.vers, "version", "", "upgrade to specific version")
f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools")
f.BoolVar(&c.DryRun, "dry-run", false, "don't change anything, just report what would change")
f.BoolVar(&c.ResetPrevious, "reset-previous-upgrade", false, "clear the previous (incomplete) upgrade status (use with care)")
f.BoolVar(&c.AssumeYes, "y", false, "answer 'yes' to confirmation prompts")
f.BoolVar(&c.AssumeYes, "yes", false, "")
}
示例10: SetFlags
// SetFlags sets utc and format flags based on user specified options.
func (c *listMachinesCommand) SetFlags(f *gnuflag.FlagSet) {
f.BoolVar(&c.isoTime, "utc", false, "display time as UTC in RFC3339 format")
c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"tabular": status.FormatMachineTabular,
})
}
示例11: SetFlags
func (c *listCredentialsCommand) SetFlags(f *gnuflag.FlagSet) {
f.BoolVar(&c.showSecrets, "show-secrets", false, "show secrets for displayed credentials")
c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"tabular": formatCredentialsTabular,
})
}
示例12: Init
func (c *RpcCommand) Init(f *gnuflag.FlagSet, args []string) error {
f.StringVar(&c.Value, "value", "", "doc")
f.BoolVar(&c.Slow, "slow", false, "doc")
if err := f.Parse(true, args); err != nil {
return err
}
return cmd.CheckEmpty(f.Args())
}
示例13: SetFlags
// SetFlags implements Command.SetFlags.
func (c *showControllerCommand) SetFlags(f *gnuflag.FlagSet) {
c.JujuCommandBase.SetFlags(f)
f.BoolVar(&c.showPasswords, "show-passwords", false, "show passwords for displayed accounts")
c.out.AddFlags(f, "yaml", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
})
}
示例14: Init
func (c *BootstrapCommand) Init(f *gnuflag.FlagSet, args []string) error {
addEnvironFlags(&c.EnvName, f)
f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping")
if err := f.Parse(true, args); err != nil {
return err
}
return cmd.CheckEmpty(f.Args())
}
示例15: SetFlags
func (c *RunCommand) SetFlags(f *gnuflag.FlagSet) {
c.out.AddFlags(f, "smart", cmd.DefaultFormatters)
f.BoolVar(&c.all, "all", false, "run the commands on all the machines")
f.DurationVar(&c.timeout, "timeout", 5*time.Minute, "how long to wait before the remote command is considered to have failed")
f.Var(cmd.NewStringsValue(nil, &c.machines), "machine", "one or more machine ids")
f.Var(cmd.NewStringsValue(nil, &c.services), "service", "one or more service names")
f.Var(cmd.NewStringsValue(nil, &c.units), "unit", "one or more unit ids")
}