本文整理汇总了Golang中launchpad/net/gnuflag.FlagSet类的典型用法代码示例。如果您正苦于以下问题:Golang FlagSet类的具体用法?Golang FlagSet怎么用?Golang FlagSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlagSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetFlags
func (w *modelCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if !w.skipFlags {
f.StringVar(&w.envName, "m", "", "juju model to operate in")
f.StringVar(&w.envName, "model", "", "")
}
w.ModelCommand.SetFlags(f)
}
示例2: SetFlags
// SetFlags implements Command.SetFlags, then calls the wrapped command's SetFlags.
func (w *sysCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if w.setFlags {
f.StringVar(&w.controllerName, "c", "", "juju controller to operate in")
f.StringVar(&w.controllerName, "controller", "", "")
}
w.ControllerCommand.SetFlags(f)
}
示例3: SetFlags
func (w *environCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if !w.skipFlags {
f.StringVar(&w.envName, "e", "", "juju environment to operate in")
f.StringVar(&w.envName, "environment", "", "")
}
w.EnvironCommand.SetFlags(f)
}
示例4: 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")
}
示例5: Init
func (c *DestroyEnvironmentCommand) Init(f *gnuflag.FlagSet, args []string) error {
addEnvironFlags(&c.EnvName, f)
if err := f.Parse(true, args); err != nil {
return err
}
return cmd.CheckEmpty(f.Args())
}
示例6: SetFlags
// SetFlags implements Command.SetFlags, then calls the wrapped command's SetFlags.
func (w *sysCommandWrapper) SetFlags(f *gnuflag.FlagSet) {
if w.setFlags {
f.StringVar(&w.systemName, "s", "", "juju system to operate in")
f.StringVar(&w.systemName, "system", "", "")
}
w.SystemCommand.SetFlags(f)
}
示例7: 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", "")
}
示例8: SetFlags
func (c *DestroyEnvironmentCommand) SetFlags(f *gnuflag.FlagSet) {
f.BoolVar(&c.assumeYes, "y", false, "Do not ask for confirmation")
f.BoolVar(&c.assumeYes, "yes", false, "")
f.BoolVar(&c.force, "force", false, "Forcefully destroy the environment, directly through the environment provider")
f.StringVar(&c.envName, "e", "", "juju environment to operate in")
f.StringVar(&c.envName, "environment", "", "juju environment to operate in")
}
示例9: Init
func (v *VersionCommand) Init(f *gnuflag.FlagSet, args []string) error {
v.out.AddFlags(f, "smart", cmd.DefaultFormatters)
if err := f.Parse(true, args); err != nil {
return err
}
return cmd.CheckEmpty(f.Args())
}
示例10: Init
func (c *portCommand) Init(f *gnuflag.FlagSet, args []string) error {
if err := f.Parse(true, args); err != nil {
return err
}
args = f.Args()
if args == nil {
return errors.New("no port specified")
}
parts := strings.Split(args[0], "/")
if len(parts) > 2 {
return fmt.Errorf("expected %s; got %q", portFormat, args[0])
}
port, err := strconv.Atoi(parts[0])
if err != nil {
return badPort(parts[0])
}
if port < 1 || port > 65535 {
return badPort(port)
}
protocol := "tcp"
if len(parts) == 2 {
protocol = strings.ToLower(parts[1])
if protocol != "tcp" && protocol != "udp" {
return fmt.Errorf(`protocol must be "tcp" or "udp"; got %q`, protocol)
}
}
c.Port = port
c.Protocol = protocol
return cmd.CheckEmpty(args[1:])
}
示例11: 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")
}
示例12: AddFlags
// AddFlags adds appropriate flags to f.
func (l *Log) AddFlags(f *gnuflag.FlagSet) {
f.StringVar(&l.Path, "log-file", "", "path to write log to")
// TODO(thumper): rename verbose to --show-log
f.BoolVar(&l.Verbose, "v", false, "if set, log additional messages")
f.BoolVar(&l.Verbose, "verbose", false, "if set, log additional messages")
f.BoolVar(&l.Debug, "debug", false, "if set, log debugging messages")
f.StringVar(&l.Config, "log-config", "", "specify log levels for modules")
}
示例13: 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,
})
}
示例14: 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,
})
}
示例15: 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,
})
}