本文整理汇总了Golang中launchpad/net/gnuflag.FlagSet.Var方法的典型用法代码示例。如果您正苦于以下问题:Golang FlagSet.Var方法的具体用法?Golang FlagSet.Var怎么用?Golang FlagSet.Var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gnuflag.FlagSet
的用法示例。
在下文中一共展示了FlagSet.Var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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")
}
示例2: SetFlags
func (c *RelationGetCommand) SetFlags(f *gnuflag.FlagSet) {
rV := newRelationIdValue(c.ctx, &c.RelationId)
c.out.AddFlags(f, "smart", cmd.DefaultFormatters)
f.Var(rV, "r", "specify a relation by id")
f.Var(rV, "relation", "")
}
示例3: SetFlags
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
c.AgentConf.AddFlags(f)
yamlBase64Var(f, &c.EnvConfig, "env-config", "", "initial environment configuration (yaml, base64 encoded)")
f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "initial environment constraints (space-separated strings)")
f.Var(&c.Hardware, "hardware", "hardware characteristics (space-separated strings)")
f.StringVar(&c.InstanceId, "instance-id", "", "unique instance-id for bootstrap machine")
}
示例4: Init
func (c *RelationGetCommand) Init(f *gnuflag.FlagSet, args []string) error {
// TODO FWER implement --format shell lp:1033511
c.out.AddFlags(f, "smart", cmd.DefaultFormatters)
f.Var(newRelationIdValue(c.ctx, &c.RelationId), "r", "specify a relation by id")
if err := f.Parse(true, args); err != nil {
return err
}
if c.RelationId == -1 {
return fmt.Errorf("no relation id specified")
}
args = f.Args()
c.Key = ""
if len(args) > 0 {
if c.Key = args[0]; c.Key == "-" {
c.Key = ""
}
args = args[1:]
}
if name, found := c.ctx.RemoteUnitName(); found {
c.UnitName = name
}
if len(args) > 0 {
c.UnitName = args[0]
args = args[1:]
}
if c.UnitName == "" {
return fmt.Errorf("no unit id specified")
}
return cmd.CheckEmpty(args)
}
示例5: 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")
}
示例6: 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.")
}
示例7: 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, "")
f.Var(newSeriesValue(nil, &c.Series), "series", "upload tools for supplied comma-separated series list (OBSOLETE)")
}
示例8: SetFlags
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
c.AgentConf.AddFlags(f)
yamlBase64Var(f, &c.EnvConfig, "env-config", "", "initial environment configuration (yaml, base64 encoded)")
f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "initial environment constraints (space-separated strings)")
f.Var(&c.Hardware, "hardware", "hardware characteristics (space-separated strings)")
f.StringVar(&c.InstanceId, "instance-id", "", "unique instance-id for bootstrap machine")
f.StringVar(&c.AdminUsername, "admin-user", "admin", "set the name for the juju admin user")
f.StringVar(&c.ImageMetadataDir, "image-metadata", "", "custom image metadata source dir")
}
示例9: SetFlags
func (c *upgradeCharmCommand) SetFlags(f *gnuflag.FlagSet) {
f.BoolVar(&c.ForceUnits, "force-units", false, "upgrade all units immediately, even if in error state")
f.StringVar((*string)(&c.Channel), "channel", "", "channel to use when getting the charm or bundle from the charm store")
f.BoolVar(&c.ForceSeries, "force-series", false, "upgrade even if series of deployed services are not supported by the new charm")
f.StringVar(&c.SwitchURL, "switch", "", "crossgrade to a different charm")
f.StringVar(&c.CharmPath, "path", "", "upgrade to a charm located at path")
f.IntVar(&c.Revision, "revision", -1, "explicit revision of current charm")
f.Var(stringMap{&c.Resources}, "resource", "resource to be uploaded to the controller")
}
示例10: SetFlags
// SetFlags handles known option flags.
func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) {
c.CommandBase.SetFlags(f)
f.Var(constraints.ConstraintsValue{Target: &c.constraints},
"constraints", "set model 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.")
f.BoolVar(&c.uploadTools, "upload-tools", false, "upload tools if bootstraping a new machine.")
}
示例11: SetFlags
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) {
c.UnitCommandBase.SetFlags(f)
f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms")
f.BoolVar(&c.BumpRevision, "u", false, "increment local charm directory revision (DEPRECATED)")
f.BoolVar(&c.BumpRevision, "upgrade", false, "")
f.Var(&c.Config, "config", "path to yaml-formatted service config")
f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set service constraints")
f.StringVar(&c.Networks, "networks", "", "bind the service to specific networks")
f.StringVar(&c.RepoPath, "repository", os.Getenv(osenv.JujuRepositoryEnvKey), "local charm repository")
}
示例12: SetFlags
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) {
c.EnvCommandBase.SetFlags(f)
c.UnitCommandBase.SetFlags(f)
f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms")
f.BoolVar(&c.BumpRevision, "u", false, "increment local charm directory revision")
f.BoolVar(&c.BumpRevision, "upgrade", false, "")
f.Var(&c.Config, "config", "path to yaml-formatted service config")
f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set service constraints")
f.StringVar(&c.RepoPath, "repository", os.Getenv("JUJU_REPOSITORY"), "local charm repository")
}
示例13: SetFlags
// SetFlags implements Command.SetFlags.
func (c *PoolListCommand) SetFlags(f *gnuflag.FlagSet) {
c.StorageCommandBase.SetFlags(f)
f.Var(cmd.NewAppendStringsValue(&c.Providers), "provider", "only show pools of these provider types")
f.Var(cmd.NewAppendStringsValue(&c.Names), "name", "only show pools with these names")
c.out.AddFlags(f, "yaml", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"tabular": formatPoolListTabular,
})
}
示例14: SetFlags
func (c *enableHACommand) SetFlags(f *gnuflag.FlagSet) {
f.IntVar(&c.NumControllers, "n", 0, "number of controllers to make available")
f.StringVar(&c.Series, "series", "", "the charm series")
f.StringVar(&c.PlacementSpec, "to", "", "the machine(s) to become controllers, bypasses constraints")
f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "additional machine constraints")
c.out.AddFlags(f, "simple", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"simple": formatSimple,
})
}
示例15: SetFlags
func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set model constraints")
f.Var(constraints.ConstraintsValue{Target: &c.BootstrapConstraints}, "bootstrap-constraints", "specify bootstrap machine constraints")
f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "specify the series of the bootstrap machine")
if featureflag.Enabled(feature.ImageMetadata) {
f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "specify the image of the bootstrap machine")
}
f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping")
f.StringVar(&c.MetadataSource, "metadata-source", "", "local path to use as tools and/or metadata source")
f.StringVar(&c.Placement, "to", "", "a placement directive indicating an instance to bootstrap")
f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "do not destroy the model if bootstrap fails")
f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "upgrade to the latest patch release tools on first bootstrap")
f.StringVar(&c.AgentVersionParam, "agent-version", "", "the version of tools to use for Juju agents")
}