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


Golang stdcli.ExitError函数代码示例

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


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

示例1: cmdRackUpdate

func cmdRackUpdate(c *cli.Context) error {
	versions, err := version.All()
	if err != nil {
		return stdcli.ExitError(err)
	}

	specified := "stable"

	if len(c.Args()) > 0 {
		specified = c.Args()[0]
	}

	version, err := versions.Resolve(specified)
	if err != nil {
		return stdcli.ExitError(err)
	}

	system, err := rackClient(c).UpdateSystem(version.Version)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Printf("Name     %s\n", system.Name)
	fmt.Printf("Status   %s\n", system.Status)
	fmt.Printf("Version  %s\n", system.Version)
	fmt.Printf("Count    %d\n", system.Count)
	fmt.Printf("Type     %s\n", system.Type)

	fmt.Println()
	fmt.Printf("Updating to version: %s\n", version.Version)
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:32,代码来源:rack.go

示例2: cmdAppParams

func cmdAppParams(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	params, err := rackClient(c).ListParameters(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	keys := []string{}

	for key, _ := range params {
		keys = append(keys, key)
	}

	sort.Strings(keys)

	t := stdcli.NewTable("NAME", "VALUE")

	for _, key := range keys {
		t.AddRow(key, params[key])
	}

	t.Print()
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:apps.go

示例3: cmdRun

func cmdRun(c *cli.Context) error {
	if c.Bool("detach") {
		return cmdRunDetached(c)
	}

	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) < 2 {
		stdcli.Usage(c, "run")
		return nil
	}

	ps := c.Args()[0]
	err = validateProcessId(c, app, ps)
	if err != nil {
		return stdcli.ExitError(err)
	}

	args := strings.Join(c.Args()[1:], " ")

	release := c.String("release")

	code, err := runAttached(c, app, ps, args, release)
	if err != nil {
		return stdcli.ExitError(err)
	}

	return cli.NewExitError("", code)
}
开发者ID:gmelika,项目名称:rack,代码行数:32,代码来源:run.go

示例4: cmdAppParamsSet

func cmdAppParamsSet(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	params := map[string]string{}

	for _, arg := range c.Args() {
		parts := strings.SplitN(arg, "=", 2)

		if len(parts) != 2 {
			return stdcli.ExitError(fmt.Errorf("invalid argument: %s", arg))
		}

		params[parts[0]] = parts[1]
	}

	fmt.Print("Updating parameters... ")

	err = rackClient(c).SetParameters(app, params)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Println("OK")
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:apps.go

示例5: cmdSSLList

func cmdSSLList(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) > 0 {
		return stdcli.ExitError(fmt.Errorf("`convox ssl` does not take arguments. Perhaps you meant `convox ssl update`?"))
	}

	if c.Bool("help") {
		stdcli.Usage(c, "")
		return nil
	}

	ssls, err := rackClient(c).ListSSL(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	t := stdcli.NewTable("TARGET", "CERTIFICATE", "DOMAIN", "EXPIRES")

	for _, ssl := range *ssls {
		t.AddRow(fmt.Sprintf("%s:%d", ssl.Process, ssl.Port), ssl.Certificate, ssl.Domain, humanizeTime(ssl.Expiration))
	}

	t.Print()
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:29,代码来源:ssl.go

示例6: cmdReleasePromote

func cmdReleasePromote(c *cli.Context) error {
	if len(c.Args()) < 1 {
		stdcli.Usage(c, "releases promote")
		return nil
	}

	release := c.Args()[0]

	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Printf("Promoting %s... ", release)

	_, err = rackClient(c).PromoteRelease(app, release)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Println("UPDATING")

	if c.Bool("wait") {
		fmt.Printf("Waiting for stabilization... ")

		if err := waitForReleasePromotion(c, app, release); err != nil {
			return stdcli.ExitError(err)
		}

		fmt.Println("OK")
	}

	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:34,代码来源:releases.go

示例7: cmdServiceURL

func cmdServiceURL(c *cli.Context) error {
	if len(c.Args()) != 1 {
		stdcli.Usage(c, "url")
		return nil
	}

	name := c.Args()[0]

	service, err := rackClient(c).GetService(name)
	if err != nil {
		return stdcli.ExitError(err)
	}

	if service.Status == "failed" {
		return stdcli.ExitError(fmt.Errorf("Service failure for %s", service.StatusReason))
	}

	if service.URL == "" {
		return stdcli.ExitError(fmt.Errorf("URL does not exist for %s", service.Name))
	}

	fmt.Printf("%s\n", service.URL)

	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:services.go

示例8: cmdAppCreate

func cmdAppCreate(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) > 0 {
		app = c.Args()[0]
	}

	if app == "" {
		return stdcli.ExitError(fmt.Errorf("must specify an app name"))
	}

	fmt.Printf("Creating app %s... ", app)

	_, err = rackClient(c).CreateApp(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Println("CREATING")

	if c.Bool("wait") {
		fmt.Printf("Waiting for %s... ", app)

		if err := waitForAppRunning(c, app); err != nil {
			stdcli.ExitError(err)
		}

		fmt.Println("OK")
	}

	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:35,代码来源:apps.go

示例9: cmdLogin

func cmdLogin(c *cli.Context) error {
	var host string

	if len(c.Args()) < 1 {
		host = "console.convox.com"
	} else {
		host = c.Args()[0]
	}

	u, err := url.Parse(host)
	if err != nil {
		return stdcli.ExitError(err)
	}

	if u.Host != "" {
		host = u.Host
	}

	password := os.Getenv("CONVOX_PASSWORD")

	if password == "" {
		password = c.String("password")
	}

	if password != "" {
		// password flag
		err = testLogin(host, password, c.App.Version)
	} else {
		// first try current login
		password, err = getLogin(host)
		err = testLogin(host, password, c.App.Version)

		// then prompt for password
		if err != nil {
			password = promptForPassword()
			err = testLogin(host, password, c.App.Version)
		}
	}

	if err != nil {
		if strings.Contains(err.Error(), "401") {
			return stdcli.ExitError(fmt.Errorf("invalid login"))
		} else {
			return stdcli.ExitError(err)
		}
	}

	err = addLogin(host, password)
	if err != nil {
		return stdcli.ExitError(err)
	}

	err = switchHost(host)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Println("Logged in successfully.")
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:60,代码来源:login.go

示例10: cmdEnvList

func cmdEnvList(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) > 0 {
		return stdcli.ExitError(fmt.Errorf("`convox env` does not take arguments. Perhaps you meant `convox env set`?"))
	}

	if c.Bool("help") {
		stdcli.Usage(c, "")
		return nil
	}

	env, err := rackClient(c).GetEnvironment(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	keys := []string{}

	for key, _ := range env {
		keys = append(keys, key)
	}

	sort.Strings(keys)

	for _, key := range keys {
		fmt.Printf("%s=%s\n", key, env[key])
	}

	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:34,代码来源:env.go

示例11: cmdReleaseInfo

func cmdReleaseInfo(c *cli.Context) error {
	if len(c.Args()) < 1 {
		stdcli.Usage(c, "release info")
		return nil
	}

	release := c.Args()[0]

	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	r, err := rackClient(c).GetRelease(app, release)
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Printf("Id       %s\n", r.Id)
	fmt.Printf("Build    %s\n", r.Build)
	fmt.Printf("Created  %s\n", r.Created)
	fmt.Printf("Env      ")

	fmt.Println(strings.Replace(r.Env, "\n", "\n         ", -1))
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:26,代码来源:releases.go

示例12: cmdRackPs

func cmdRackPs(c *cli.Context) error {
	system, err := rackClient(c).GetSystem()
	if err != nil {
		return stdcli.ExitError(err)
	}

	ps, err := rackClient(c).GetProcesses(system.Name, c.Bool("stats"))
	if err != nil {
		return stdcli.ExitError(err)
	}

	if c.Bool("stats") {
		fm, err := rackClient(c).ListFormation(system.Name)
		if err != nil {
			return stdcli.ExitError(err)
		}

		displayProcessesStats(ps, fm)
		return nil
	}

	displayProcesses(ps)

	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:25,代码来源:rack.go

示例13: cmdSSLUpdate

func cmdSSLUpdate(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) < 2 {
		stdcli.Usage(c, "update")
		return nil
	}

	target := c.Args()[0]

	parts := strings.Split(target, ":")

	if len(parts) != 2 {
		return stdcli.ExitError(fmt.Errorf("target must be process:port"))
	}

	fmt.Printf("Updating certificate... ")

	_, err = rackClient(c).UpdateSSL(app, parts[0], parts[1], c.Args()[1])
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Println("OK")
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:29,代码来源:ssl.go

示例14: cmdRackParams

func cmdRackParams(c *cli.Context) error {
	system, err := rackClient(c).GetSystem()
	if err != nil {
		return stdcli.ExitError(err)
	}

	params, err := rackClient(c).ListParameters(system.Name)
	if err != nil {
		return stdcli.ExitError(err)
	}

	keys := []string{}

	for key, _ := range params {
		keys = append(keys, key)
	}

	sort.Strings(keys)

	t := stdcli.NewTable("NAME", "VALUE")

	for _, key := range keys {
		t.AddRow(key, params[key])
	}

	t.Print()
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:28,代码来源:rack.go

示例15: cmdInstancesList

func cmdInstancesList(c *cli.Context) error {
	if len(c.Args()) > 0 {
		return stdcli.ExitError(fmt.Errorf("`convox instances` does not take arguments. Perhaps you meant `convox instances ssh`?"))
	}

	if c.Bool("help") {
		stdcli.Usage(c, "")
		return nil
	}

	instances, err := rackClient(c).GetInstances()
	if err != nil {
		return stdcli.ExitError(err)
	}

	t := stdcli.NewTable("ID", "AGENT", "STATUS", "STARTED", "PS", "CPU", "MEM")

	for _, i := range instances {
		agent := "off"
		if i.Agent {
			agent = "on"
		}

		t.AddRow(i.Id, agent, i.Status,
			humanizeTime(i.Started),
			strconv.Itoa(i.Processes),
			fmt.Sprintf("%0.2f%%", i.Cpu*100),
			fmt.Sprintf("%0.2f%%", i.Memory*100))
	}

	t.Print()
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:33,代码来源:instances.go


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