當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cmd.CheckEmpty函數代碼示例

本文整理匯總了Golang中launchpad/net/juju-core/cmd.CheckEmpty函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckEmpty函數的具體用法?Golang CheckEmpty怎麽用?Golang CheckEmpty使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CheckEmpty函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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:])
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:30,代碼來源:ports.go

示例2: Init

func (c *PublishCommand) Init(args []string) error {
	if len(args) == 0 {
		return nil
	}
	c.URL = args[0]
	return cmd.CheckEmpty(args[1:])
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:7,代碼來源:publish.go

示例3: 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())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:7,代碼來源:version.go

示例4: Init

func (c *ExposeCommand) Init(args []string) error {
	if len(args) == 0 {
		return errors.New("no service name specified")
	}
	c.ServiceName = args[0]
	return cmd.CheckEmpty(args[1:])
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:7,代碼來源:expose.go

示例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())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:7,代碼來源:destroyenvironment.go

示例6: Init

func (c *UpgradeJujuCommand) Init(args []string) error {
	if c.vers != "" {
		vers, err := version.Parse(c.vers)
		if err != nil {
			return err
		}
		if vers.Major != version.Current.Major {
			return fmt.Errorf("cannot upgrade to version incompatible with CLI")
		}
		if c.UploadTools && vers.Build != 0 {
			// TODO(fwereade): when we start taking versions from actual built
			// code, we should disable --version when used with --upload-tools.
			// For now, it's the only way to experiment with version upgrade
			// behaviour live, so the only restriction is that Build cannot
			// be used (because its value needs to be chosen internally so as
			// not to collide with existing tools).
			return fmt.Errorf("cannot specify build number when uploading tools")
		}
		c.Version = vers
	}
	if len(c.Series) > 0 && !c.UploadTools {
		return fmt.Errorf("--series requires --upload-tools")
	}
	return cmd.CheckEmpty(args)
}
開發者ID:CSRedRat,項目名稱:juju-core,代碼行數:25,代碼來源:upgradejuju.go

示例7: Init

func (c *RemoteCommand) Init(f *gnuflag.FlagSet, args []string) error {
	f.StringVar(&c.msg, "error", "", "if set, fail")
	if err := f.Parse(true, args); err != nil {
		return err
	}
	return cmd.CheckEmpty(f.Args())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:7,代碼來源:main_test.go

示例8: 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)
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:30,代碼來源:relation-get.go

示例9: 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())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:8,代碼來源:bootstrap.go

示例10: Init

func (c *GetCommand) Init(args []string) error {
	// TODO(dfc) add --schema-only
	if len(args) == 0 {
		return errors.New("no service name specified")
	}
	c.ServiceName = args[0]
	return cmd.CheckEmpty(args[1:])
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:8,代碼來源:get.go

示例11: 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())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:8,代碼來源:server_test.go

示例12: Init

func (c *GetConstraintsCommand) Init(args []string) error {
	if len(args) > 0 {
		if !state.IsServiceName(args[0]) {
			return fmt.Errorf("invalid service name %q", args[0])
		}
		c.ServiceName, args = args[0], args[1:]
	}
	return cmd.CheckEmpty(args)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:9,代碼來源:constraints.go

示例13: Init

func (c *TestCommand) Init(f *gnuflag.FlagSet, args []string) error {
	if !c.Minimal {
		f.StringVar(&c.Option, "option", "", "option-doc")
	}
	if err := f.Parse(true, args); err != nil {
		return err
	}
	return cmd.CheckEmpty(f.Args())
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:9,代碼來源:util_test.go

示例14: Init

func (c *DestroyServiceCommand) Init(args []string) error {
	if len(args) == 0 {
		return fmt.Errorf("no service specified")
	}
	if !state.IsServiceName(args[0]) {
		return fmt.Errorf("invalid service name %q", args[0])
	}
	c.ServiceName, args = args[0], args[1:]
	return cmd.CheckEmpty(args)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:10,代碼來源:destroyservice.go

示例15: Init

func (c *UnitGetCommand) Init(args []string) error {
	if args == nil {
		return errors.New("no setting specified")
	}
	if args[0] != "private-address" && args[0] != "public-address" {
		return fmt.Errorf("unknown setting %q", args[0])
	}
	c.Key = args[0]
	return cmd.CheckEmpty(args[1:])
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:10,代碼來源:unit-get.go


注:本文中的launchpad/net/juju-core/cmd.CheckEmpty函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。