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


Golang Context.IsSet方法代码示例

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


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

示例1: runRun

func runRun(c *cli.Context) {
	if runtime.GOOS == "windows" {
		printFatal("Not supported on Windows")
		os.Exit(2)
	}

	stack := mustStack(c)
	if c.String("service") != "" && stack.Framework != "docker" {
		printFatal("The service option only applies to docker stacks")
		os.Exit(2)
	}

	serverName := c.String("server")

	if !c.IsSet("service") {
		if len(c.Args()) != 1 {
			cli.ShowCommandHelp(c, "run")
			os.Exit(2)
		}
	}

	userCommand := ""
	if len(c.Args()) == 1 {
		userCommand = c.Args()[0]
	}

	servers, err := client.Servers(stack.Uid)
	if err != nil {
		printFatal(err.Error())
	}

	server, err := findServer(servers, serverName)
	if err != nil {
		printFatal(err.Error())
	}

	if server == nil {
		printFatal("Server '" + serverName + "' not found")
	}

	if c.String("service") != "" {
		// fetch service information for existing server/command
		service, err := client.GetService(stack.Uid, c.String("service"), &server.Uid, &userCommand)
		must(err)

		userCommand = service.WrapCommand
	}

	includeTty := c.String("service") != ""
	err = SshToServerForCommand(*server, userCommand, includeTty)
	if err != nil {
		printFatal(err.Error())
	}
}
开发者ID:sgtpepper43,项目名称:cx,代码行数:54,代码来源:run.go

示例2: runNewBackup

func runNewBackup(c *cli.Context) {
	stack := mustStack(c)

	var flagDbTypes *string

	if c.IsSet("dbtypes") {
		flagDbTypes = new(string)
		*flagDbTypes = c.String("dbtypes")
	}

	var flagFrequency *string

	if c.IsSet("frequency") {
		flagFrequency = new(string)
		*flagFrequency = c.String("frequency")
	}

	var flagKeep *int

	if c.IsSet("keep") {
		flagKeep = new(int)
		*flagKeep = c.Int("keep")
	}

	var flagGzip *bool

	if c.IsSet("gzip") {
		flagGzip = new(bool)
		*flagGzip = c.Bool("gzip")
	}

	var flagExcludetables *string

	if c.IsSet("exclude-tables") {
		flagExcludetables = new(string)
		*flagExcludetables = c.String("exclude-tables")
	}

	var flagRunonreplica *bool

	if c.IsSet("run-on-replica") {
		flagRunonreplica = new(bool)
		*flagRunonreplica = c.Bool("run-on-replica")
	}

	err := client.NewBackup(stack.Uid, flagDbTypes, flagFrequency, flagKeep, flagGzip, flagExcludetables, flagRunonreplica)

	if err != nil {
		printFatal("Error during backup creation: " + err.Error())
		return
	}

	fmt.Println("queued for creation")
}
开发者ID:sgtpepper43,项目名称:cx,代码行数:54,代码来源:backups-new.go


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