本文整理汇总了Golang中github.com/juju/gnuflag.FlagSet类的典型用法代码示例。如果您正苦于以下问题:Golang FlagSet类的具体用法?Golang FlagSet怎么用?Golang FlagSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlagSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetFlags
func (w *modelCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if !w.skipModelFlags {
f.StringVar(&w.modelName, "m", "", "Model to operate in. Accepts [<controller name>:]<model name>")
f.StringVar(&w.modelName, "model", "", "")
}
w.ModelCommand.SetFlags(f)
}
示例2: AddFlags
// AddFlags injects common agent flags into f.
func (c *agentConf) AddFlags(f *gnuflag.FlagSet) {
// TODO(dimitern) 2014-02-19 bug 1282025
// We need to pass a config location here instead and
// use it to locate the conf and the infer the data-dir
// from there instead of passing it like that.
f.StringVar(&c.dataDir, "data-dir", util.DataDir, "directory for juju data")
}
示例3: SetFlags
// SetFlags implements Command.SetFlags, then calls the wrapped command's SetFlags.
func (w *sysCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if w.setControllerFlags {
f.StringVar(&w.controllerName, "c", "", "Controller to operate in")
f.StringVar(&w.controllerName, "controller", "", "")
}
w.ControllerCommand.SetFlags(f)
}
示例4: SetFlags
// SetFlags is defined on the cmd.Command interface.
func (c *listCommand) SetFlags(f *gnuflag.FlagSet) {
c.SubnetCommandBase.SetFlags(f)
c.Out.AddFlags(f, "yaml", output.DefaultFormatters)
f.StringVar(&c.SpaceName, "space", "", "Filter results by space name")
f.StringVar(&c.ZoneName, "zone", "", "Filter results by zone name")
}
示例5: 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")
}
示例6: SetFlags
// SetFlags implements Command.SetFlags.
func (c *showControllerCommand) SetFlags(f *gnuflag.FlagSet) {
c.JujuCommandBase.SetFlags(f)
f.BoolVar(&c.showPasswords, "show-password", false, "Show password for logged in user")
c.out.AddFlags(f, "yaml", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
})
}
示例7: SetFlags
func (c *statusHistoryCommand) SetFlags(f *gnuflag.FlagSet) {
c.ModelCommandBase.SetFlags(f)
f.StringVar(&c.outputContent, "type", "unit", "Type of statuses to be displayed [agent|workload|combined|machine|machineInstance|container|containerinstance]")
f.IntVar(&c.backlogSize, "n", 0, "Returns the last N logs (cannot be combined with --days or --date)")
f.IntVar(&c.backlogSizeDays, "days", 0, "Returns the logs for the past <days> days (cannot be combined with -n or --date)")
f.StringVar(&c.backlogDate, "date", "", "Returns logs for any date after the passed one, the expected date format is YYYY-MM-DD (cannot be combined with -n or --days)")
f.BoolVar(&c.isoTime, "utc", false, "Display time as UTC in RFC3339 format")
}
示例8: SetFlags
// SetFlags handles known option flags.
func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) {
c.CommandBase.SetFlags(f)
f.StringVar(&c.constraintsStr, "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.buildAgent, "build-agent", false, "Build binary agent if bootstraping a new machine")
}
示例9: SetFlags
func (c *validateImageMetadataCommand) SetFlags(f *gnuflag.FlagSet) {
c.out.AddFlags(f, "yaml", output.DefaultFormatters)
f.StringVar(&c.providerType, "p", "", "the provider type eg ec2, openstack")
f.StringVar(&c.metadataDir, "d", "", "directory where metadata files are found")
f.StringVar(&c.series, "s", "", "the series for which to validate (overrides env config series)")
f.StringVar(&c.region, "r", "", "the region for which to validate (overrides env config region)")
f.StringVar(&c.endpoint, "u", "", "the cloud endpoint URL for which to validate (overrides env config endpoint)")
f.StringVar(&c.stream, "stream", "", "the images stream (defaults to released)")
}
示例10: SetFlags
func (c *listCredentialsCommand) SetFlags(f *gnuflag.FlagSet) {
c.CommandBase.SetFlags(f)
f.BoolVar(&c.showSecrets, "show-secrets", false, "Show secrets")
c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"tabular": formatCredentialsTabular,
})
}
示例11: SetFlags
// SetFlags implements part of the cmd.Command interface.
func (c *defaultsCommand) SetFlags(f *gnuflag.FlagSet) {
c.ControllerCommandBase.SetFlags(f)
c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
"tabular": formatDefaultConfigTabular,
})
f.Var(cmd.NewAppendStringsValue(&c.reset), "reset", "Reset the provided comma delimited keys")
}
示例12: SetFlags
// SetFlags implements part of the cmd.Command interface.
func (c *configCommand) SetFlags(f *gnuflag.FlagSet) {
c.ModelCommandBase.SetFlags(f)
c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{
"json": cmd.FormatJson,
"tabular": formatConfigTabular,
"yaml": cmd.FormatYaml,
})
f.BoolVar(&c.reset, "reset", false, "Reset the provided keys to be empty")
}
示例13: SetFlags
// SetFlags is defined on the cmd.Command interface.
func (c *createCommand) SetFlags(f *gnuflag.FlagSet) {
c.SubnetCommandBase.SetFlags(f)
f.BoolVar(&c.IsPublic, "public", false, "enable public access with shadow addresses")
f.BoolVar(&c.IsPrivate, "private", true, "disable public access with shadow addresses")
// Because SetFlags is called before Parse, we cannot
// use f.Visit() here to check both flags were not
// specified at once. So we store the flag set and
// defer the check to Init().
c.flagSet = f
}
示例14: getFlags
// getFlags returns the flags with the given names. Only flags that are set and
// whose name is included in flagNames are included.
func getFlags(flagSet *gnuflag.FlagSet, flagNames []string) []string {
flags := make([]string, 0, flagSet.NFlag())
flagSet.Visit(func(flag *gnuflag.Flag) {
for _, name := range flagNames {
if flag.Name == name {
flags = append(flags, flagWithMinus(name))
}
}
})
return flags
}
示例15: SetFlags
// SetFlags implements cmd.Command.SetFlags.
func (c *ShowServiceCommand) SetFlags(f *gnuflag.FlagSet) {
c.ModelCommandBase.SetFlags(f)
const defaultFormat = "tabular"
c.out.AddFlags(f, defaultFormat, map[string]cmd.Formatter{
defaultFormat: FormatSvcTabular,
"yaml": cmd.FormatYaml,
"json": cmd.FormatJson,
})
f.BoolVar(&c.details, "details", false, "show detailed information about resources used by each unit.")
}