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


Golang cliutils.ExitOnErr函数代码示例

本文整理汇总了Golang中github.com/jfrogdev/jfrog-cli-go/utils/cliutils.ExitOnErr函数的典型用法代码示例。如果您正苦于以下问题:Golang ExitOnErr函数的具体用法?Golang ExitOnErr怎么用?Golang ExitOnErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: upload

func upload(c *cli.Context) {
	if c.NArg() < 2 || c.NArg() > 3 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	localPath := c.Args().Get(0)
	versionDetails, err := utils.CreateVersionDetails(c.Args().Get(1))
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	uploadPath := c.Args().Get(2)
	if strings.HasPrefix(uploadPath, "/") {
		uploadPath = uploadPath[1:]
	}

	uploadFlags, err := createUploadFlags(c)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	uploaded, failed, err := commands.Upload(versionDetails, localPath, uploadPath, uploadFlags)
	cliutils.ExitOnErr(err)
	if failed > 0 {
		if uploaded > 0 {
			cliutils.Exit(cliutils.ExitCodeWarning, "")
		}
		cliutils.Exit(cliutils.ExitCodeError, "")
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:27,代码来源:cli.go

示例2: searchCmd

func searchCmd(c *cli.Context) {
	if c.NArg() > 0 && c.IsSet("spec") {
		cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage())
	}
	if !(c.NArg() == 1 || (c.NArg() == 0 && c.IsSet("spec"))) {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}

	var searchSpec *utils.SpecFiles
	if c.IsSet("spec") {
		var err error
		searchSpec, err = getSearchSpec(c)
		cliutils.ExitOnErr(err)
	} else {
		searchSpec = createDefaultSearchSpec(c)
	}

	flags, err := createSearchFlags(c)
	cliutils.ExitOnErr(err)
	SearchResult, err := commands.Search(searchSpec, flags)
	cliutils.ExitOnErr(err)
	result, err := json.Marshal(SearchResult)
	cliutils.ExitOnErr(err)

	fmt.Println(string(cliutils.IndentJson(result)))
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:26,代码来源:cli.go

示例3: logs

func logs(c *cli.Context) {
	bintrayDetails, err := createBintrayDetails(c, true)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	if c.NArg() == 1 {
		packageDetails, err := utils.CreatePackageDetails(c.Args().Get(0))
		cliutils.ExitOnErr(err)
		err = commands.LogsList(packageDetails, bintrayDetails)
		cliutils.ExitOnErr(err)
	} else if c.NArg() == 3 {
		if c.Args().Get(0) == "download" {
			packageDetails, err := utils.CreatePackageDetails(c.Args().Get(1))
			if err != nil {
				cliutils.Exit(cliutils.ExitCodeError, err.Error())
			}
			err = commands.DownloadLog(packageDetails, c.Args().Get(2), bintrayDetails)
			cliutils.ExitOnErr(err)
		} else {
			cliutils.Exit(cliutils.ExitCodeError, "Unkown argument "+c.Args().Get(0)+". "+cliutils.GetDocumentationMessage())
		}
	} else {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:25,代码来源:cli.go

示例4: uploadCmd

func uploadCmd(c *cli.Context) {
	if c.NArg() > 0 && c.IsSet("spec") {
		cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage())
	}
	if !(c.NArg() == 2 || (c.NArg() == 0 && c.IsSet("spec"))) {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}

	var uploadSpec *utils.SpecFiles
	if c.IsSet("spec") {
		var err error
		uploadSpec, err = getUploadSpec(c)
		cliutils.ExitOnErr(err)
	} else {
		uploadSpec = createDefaultUploadSpec(c)
	}

	flags, err := createUploadFlags(c)
	cliutils.ExitOnErr(err)
	uploaded, failed, err := commands.Upload(uploadSpec, flags)
	cliutils.ExitOnErr(err)
	if failed > 0 {
		if uploaded > 0 {
			cliutils.Exit(cliutils.ExitCodeWarning, "")
		}
		cliutils.Exit(cliutils.ExitCodeError, "")
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:28,代码来源:cli.go

示例5: buildDistributeCmd

func buildDistributeCmd(c *cli.Context) {
	if c.NArg() != 3 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	buildDistributeFlags, err := createBuildDistributionFlags(c)
	if err != nil {
		cliutils.ExitOnErr(err)
	}
	err = commands.BuildDistribute(c.Args().Get(0), c.Args().Get(1), c.Args().Get(2), buildDistributeFlags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:11,代码来源:cli.go

示例6: deleteVersion

func deleteVersion(c *cli.Context) {
	if c.NArg() != 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	versionDetails, err := utils.CreateVersionDetails(c.Args().Get(0))
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	bintrayDetails, err := createBintrayDetails(c, true)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}

	if !c.Bool("quiet") {
		var confirm string
		fmt.Print("Delete version " + versionDetails.Version +
			" of package " + versionDetails.Package + "? (y/n): ")
		fmt.Scanln(&confirm)
		if !cliutils.ConfirmAnswer(confirm) {
			return
		}
	}
	err = commands.DeleteVersion(versionDetails, bintrayDetails)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:25,代码来源:cli.go

示例7: buildPublishCmd

func buildPublishCmd(c *cli.Context) {
	vlidateBuildInfoArgument(c)
	buildInfoFlags, err := createBuildInfoFlags(c)
	cliutils.ExitOnErrWithMsg(err)
	err = commands.BuildPublish(c.Args().Get(0), c.Args().Get(1), buildInfoFlags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:7,代码来源:cli.go

示例8: configCmd

func configCmd(c *cli.Context) {
	if len(c.Args()) > 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	} else if len(c.Args()) == 1 {
		if c.Args()[0] == "show" {
			commands.ShowConfig()
		} else if c.Args()[0] == "clear" {
			commands.ClearConfig()
		} else {
			cliutils.Exit(cliutils.ExitCodeError, "Unknown argument '"+c.Args()[0]+"'. Available arguments are 'show' and 'clear'.")
		}
	} else {
		configFlags, err := createConfigFlags(c)
		cliutils.ExitOnErr(err)
		_, err = commands.Config(configFlags.ArtDetails, nil, configFlags.Interactive, configFlags.EncPassword)
		cliutils.ExitOnErr(err)
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:18,代码来源:cli.go

示例9: deleteCmd

func deleteCmd(c *cli.Context) {
	if c.NArg() > 0 && c.IsSet("spec") {
		cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage())
	}
	if !(c.NArg() == 1 || (c.NArg() == 0 && c.IsSet("spec"))) {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}

	var deleteSpec *utils.SpecFiles
	if c.IsSet("spec") {
		var err error
		deleteSpec, err = getDeleteSpec(c)
		cliutils.ExitOnErr(err)
	} else {
		deleteSpec = createDefaultDeleteSpec(c)
	}

	flags, err := createDeleteFlags(c)
	cliutils.ExitOnErr(err)
	if !c.Bool("quiet") {
		pathsToDelete, err := commands.GetPathsToDelete(deleteSpec, flags)
		cliutils.ExitOnErr(err)
		if len(pathsToDelete) < 1 {
			return
		}
		for _, v := range pathsToDelete {
			fmt.Println("  " + v.GetFullUrl())
		}
		var confirm string
		fmt.Print("Are you sure you want to delete the above paths? (y/n): ")
		fmt.Scanln(&confirm)
		if !cliutils.ConfirmAnswer(confirm) {
			return
		}
		err = commands.DeleteFiles(pathsToDelete, flags)
		cliutils.ExitOnErr(err)
	} else {
		err = commands.Delete(deleteSpec, flags)
		cliutils.ExitOnErr(err)
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:41,代码来源:cli.go

示例10: copyCmd

func copyCmd(c *cli.Context) {
	if c.NArg() > 0 && c.IsSet("spec") {
		cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage())
	}
	if !(c.NArg() == 2 || (c.NArg() == 0 && c.IsSet("spec"))) {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}

	var copySpec *utils.SpecFiles
	if c.IsSet("spec") {
		var err error
		copySpec, err = getMoveSpec(c)
		cliutils.ExitOnErr(err)
	} else {
		copySpec = createDefaultMoveSpec(c)
	}

	flags, err := createMoveFlags(c)
	cliutils.ExitOnErr(err)
	err = commands.Copy(copySpec, flags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:22,代码来源:cli.go

示例11: downloadVersion

func downloadVersion(c *cli.Context) {
	if c.NArg() < 1 || c.NArg() > 2 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	versionDetails, err := commands.CreateVersionDetailsForDownloadVersion(c.Args().Get(0))
	cliutils.ExitOnErr(err)
	targetPath := c.Args().Get(1)
	if strings.HasPrefix(targetPath, "/") {
		targetPath = targetPath[1:]
	}
	flags, err := createDownloadFlags(c)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	downloaded, failed, err := commands.DownloadVersion(versionDetails, targetPath, flags)
	cliutils.ExitOnErr(err)
	if failed > 0 {
		if downloaded > 0 {
			cliutils.Exit(cliutils.ExitCodeWarning, "")
		}
		cliutils.Exit(cliutils.ExitCodeError, "")
	}
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:23,代码来源:cli.go

示例12: handleEntitlements

func handleEntitlements(c *cli.Context) {
	if c.NArg() == 0 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	if c.NArg() == 1 {
		bintrayDetails, err := createBintrayDetails(c, true)
		cliutils.ExitOnErr(err)
		details, err := entitlements.CreateVersionDetails(c.Args().Get(0))
		cliutils.ExitOnErr(err)
		err = entitlements.ShowEntitlements(bintrayDetails, details)
		cliutils.ExitOnErr(err)
		return
	}
	if c.NArg() != 2 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	details, err := entitlements.CreateVersionDetails(c.Args().Get(1))
	cliutils.ExitOnErr(err)

	var flags *entitlements.EntitlementFlags
	switch c.Args().Get(0) {
	case "show":
		flags, err = createEntitlementFlagsForShowAndDelete(c)
		cliutils.ExitOnErr(err)
		err = entitlements.ShowEntitlement(flags, details)
	case "create":
		flags, err = createEntitlementFlagsForCreate(c)
		cliutils.ExitOnErr(err)
		err = entitlements.CreateEntitlement(flags, details)
	case "update":
		flags, err = createEntitlementFlagsForUpdate(c)
		cliutils.ExitOnErr(err)
		err = entitlements.UpdateEntitlement(flags, details)
	case "delete":
		flags, err = createEntitlementFlagsForShowAndDelete(c)
		cliutils.ExitOnErr(err)
		err = entitlements.DeleteEntitlement(flags, details)
	default:
		cliutils.Exit(cliutils.ExitCodeError, "Expecting show, create, update or delete before "+c.Args().Get(1)+". Got "+c.Args().Get(0))
	}
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:42,代码来源:cli.go

示例13: updatePackage

func updatePackage(c *cli.Context) {
	if c.NArg() != 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	packageDetails, err := utils.CreatePackageDetails(c.Args().Get(0))
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	packageFlags, err := createPackageFlags(c)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	err = commands.UpdatePackage(packageDetails, packageFlags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:15,代码来源:cli.go

示例14: gpgSignVersion

func gpgSignVersion(c *cli.Context) {
	if c.NArg() != 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	versionDetails, err := utils.CreateVersionDetails(c.Args().Get(0))
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	flags, err := createBintrayDetails(c, true)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	err = commands.GpgSignVersion(versionDetails, c.String("passphrase"), flags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:15,代码来源:cli.go

示例15: signUrl

func signUrl(c *cli.Context) {
	if c.NArg() != 1 {
		cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
	}
	urlSigningDetails, err := utils.CreatePathDetails(c.Args().Get(0))
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	urlSigningFlags, err := createUrlSigningFlags(c)
	if err != nil {
		cliutils.Exit(cliutils.ExitCodeError, err.Error())
	}
	err = commands.SignVersion(urlSigningDetails, urlSigningFlags)
	cliutils.ExitOnErr(err)
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:15,代码来源:cli.go


注:本文中的github.com/jfrogdev/jfrog-cli-go/utils/cliutils.ExitOnErr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。