当前位置: 首页>>代码示例>>Golang>>正文


Golang Command.Usage方法代码示例

本文整理汇总了Golang中github.com/appc/acbuild/Godeps/_workspace/src/github.com/spf13/cobra.Command.Usage方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Usage方法的具体用法?Golang Command.Usage怎么用?Golang Command.Usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/appc/acbuild/Godeps/_workspace/src/github.com/spf13/cobra.Command的用法示例。


在下文中一共展示了Command.Usage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: runRun

func runRun(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("run: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("run: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Running: %v", args)
	}

	err = lib.Run(tmpacipath(), depstorepath(), targetpath(), scratchpath(), workpath(), args, insecure)

	if err != nil {
		stderr("run: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:31,代码来源:run.go

示例2: runCopy

func runCopy(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 2 {
		stderr("copy: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("copy: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("copy: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Copying host:%s to aci:%s", args[0], args[1])
	}

	err = lib.Copy(tmpacipath(), args[0], args[1])

	if err != nil {
		stderr("copy: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:35,代码来源:copy.go

示例3: runSetGroup

func runSetGroup(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 1 {
		stderr("set-group: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("set-group: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("set-group: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Setting group to %s", args[0])
	}

	err = lib.SetGroup(tmpacipath(), args[0])

	if err != nil {
		stderr("set-group: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:35,代码来源:set-group.go

示例4: runRmDep

func runRmDep(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 1 {
		stderr("dependency remove: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("dependency remove: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("dependency remove: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Removing dependency %q", args[0])
	}

	err = lib.RemoveDependency(tmpacipath(), args[0])

	if err != nil {
		stderr("dependency remove: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:35,代码来源:dependency.go

示例5: runAddMount

func runAddMount(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 2 {
		stderr("mount add: incorrect number of arguments")
		return 1
	}

	if debug {
		if readOnly {
			stderr("Adding read only mount point %q=%q", args[0], args[1])
		} else {
			stderr("Adding mount point %q=%q", args[0], args[1])
		}
	}

	err := newACBuild().AddMount(args[0], args[1], readOnly)

	if err != nil {
		stderr("mount add: %v", err)
		return 1
	}

	return 0
}
开发者ID:aaronlevy,项目名称:acbuild,代码行数:27,代码来源:mount.go

示例6: runAddPort

func runAddPort(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 3 {
		stderr("port add: incorrect number of arguments")
		return 1
	}
	port, err := strconv.ParseUint(args[2], 10, 16)
	if err != nil {
		stderr("port add: port must be a positive number between 0 and 65535")
		return 1
	}

	if debug {
		stderr("Adding port %q=%q", args[0], args[1])
	}

	err = newACBuild().AddPort(args[0], args[1], uint(port), count, socketActivated)

	if err != nil {
		stderr("port add: %v", err)
		return getErrorCode(err)
	}

	return 0
}
开发者ID:kinvolk,项目名称:acbuild,代码行数:28,代码来源:port.go

示例7: runRemoveEnv

func runRemoveEnv(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) > 1 {
		stderr("environment remove: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("environment remove: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("environment remove: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Removing environment variable %q", args[0])
	}

	err = lib.RemoveEnv(tmpacipath(), args[0])

	if err != nil {
		stderr("environment remove: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:35,代码来源:environment.go

示例8: runAddLabel

func runAddLabel(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 2 {
		stderr("label add: incorrect number of arguments")
		return 1
	}

	lockfile, err := getLock()
	if err != nil {
		stderr("label add: %v", err)
		return 1
	}
	defer func() {
		if err := releaseLock(lockfile); err != nil {
			stderr("label add: %v", err)
			exit = 1
		}
	}()

	if debug {
		stderr("Adding label %q=%q", args[0], args[1])
	}

	err = lib.AddLabel(tmpacipath(), args[0], args[1])

	if err != nil {
		stderr("label add: %v", err)
		return 1
	}

	return 0
}
开发者ID:apcera,项目名称:acbuild,代码行数:35,代码来源:label.go

示例9: runCopy

func runCopy(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if (!toDir && len(args) != 2) || (toDir && len(args) < 2) {
		stderr("copy: incorrect number of arguments")
		return 1
	}

	if debug {
		stderr("Copying host:%s to aci:%s", args[0], args[1])
	}

	var err error
	if toDir {
		err = newACBuild().CopyToDir(args[:len(args)-1], args[len(args)-1])
	} else {
		err = newACBuild().CopyToTarget(args[0], args[1])
	}

	if err != nil {
		stderr("copy: %v", err)
		return getErrorCode(err)
	}

	return 0
}
开发者ID:rhencke,项目名称:acbuild,代码行数:28,代码来源:copy.go

示例10: runAddDep

func runAddDep(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}
	if len(args) != 1 {
		stderr("dependency add: incorrect number of arguments")
		return 1
	}

	if debug {
		stderr("Adding dependency %q", args[0])
	}

	app, err := discovery.NewAppFromString(args[0])
	if err != nil {
		stderr("dependency add: couldn't parse dependency name: %v", err)
		return 1
	}

	appcLabels := types.Labels(labels)

	for name, value := range app.Labels {
		if _, ok := appcLabels.Get(string(name)); ok {
			stderr("multiple %s labels specified", name)
			return 1
		}
		appcLabels = append(appcLabels, types.Label{
			Name:  name,
			Value: value,
		})
	}

	var hash *types.Hash
	if imageId != "" {
		var err error
		hash, err = types.NewHash(imageId)
		if err != nil {
			stderr("dependency add: couldn't parse image ID: %v", err)
			return 1
		}
	}

	err = newACBuild().AddDependency(app.Name, hash, appcLabels, size)

	if err != nil {
		stderr("dependency add: %v", err)
		return getErrorCode(err)
	}

	return 0
}
开发者ID:rhencke,项目名称:acbuild,代码行数:52,代码来源:dependency.go

示例11: runCat

func runCat(cmd *cobra.Command, args []string) (exit int) {
	if len(args) != 0 {
		cmd.Usage()
		return 1
	}

	if debug {
		stderr("Printing manifest from current build")
	}

	err := newACBuild().CatManifest(prettyPrint)
	if err != nil {
		stderr("cat-manifest: %v", err)
		return 1
	}

	return 0
}
开发者ID:kinvolk,项目名称:acbuild,代码行数:18,代码来源:cat-manifest.go

示例12: runSetPreStart

func runSetPreStart(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}

	if debug {
		stderr("Setting pre-start event handler to %v", args)
	}

	err := newACBuild().SetPreStart(args)

	if err != nil {
		stderr("pre-start: %v", err)
		return 1
	}

	return 0
}
开发者ID:kinvolk,项目名称:acbuild,代码行数:19,代码来源:set-event-handlers.go

示例13: runWrite

func runWrite(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}

	if debug {
		stderr("Writing ACI to %s", args[0])
	}

	err := newACBuild().Write(args[0], overwrite, sign, args[1:])

	if err != nil {
		stderr("write: %v", err)
		return 1
	}

	return 0
}
开发者ID:aaronlevy,项目名称:acbuild,代码行数:19,代码来源:write.go

示例14: runSetPostStop

func runSetPostStop(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}

	if debug {
		stderr("Setting post-stop event handler to %v", args)
	}

	err := newACBuild().SetPostStop(args)

	if err != nil {
		stderr("post-stop: %v", err)
		return 1
	}

	return 0
}
开发者ID:kinvolk,项目名称:acbuild,代码行数:19,代码来源:set-event-handlers.go

示例15: runRun

func runRun(cmd *cobra.Command, args []string) (exit int) {
	if len(args) == 0 {
		cmd.Usage()
		return 1
	}

	if debug {
		stderr("Running: %v", args)
	}

	err := lib.Run(tmpacipath(), depstorepath(), targetpath(), scratchpath(), workpath(), args, insecure)

	if err != nil {
		stderr("run: %v", err)
		return 1
	}

	return 0
}
开发者ID:jaypipes,项目名称:acbuild,代码行数:19,代码来源:run.go


注:本文中的github.com/appc/acbuild/Godeps/_workspace/src/github.com/spf13/cobra.Command.Usage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。