• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang stdcli.DirApp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: cmdEnvSet

func cmdEnvSet(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	resp, err := fetchEnv(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var old map[string]string
	err = json.Unmarshal(resp, &old)

	if err != nil {
		stdcli.Error(err)
		return
	}

	data := ""

	for key, value := range old {
		data += fmt.Sprintf("%s=%s\n", key, value)
	}

	stat, err := os.Stdin.Stat()

	if err != nil {
		stdcli.Error(err)
		return
	}

	if (stat.Mode() & os.ModeCharDevice) == 0 {
		in, err := ioutil.ReadAll(os.Stdin)

		if err != nil {
			stdcli.Error(err)
			return
		}

		data += string(in)
	}

	for _, value := range c.Args() {
		data += fmt.Sprintf("%s\n", value)
	}

	path := fmt.Sprintf("/apps/%s/environment", app)

	resp, err = ConvoxPost(path, data)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:60,代码来源:env.go


示例2: cmdEnvGetAll

func cmdEnvGetAll(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	resp, err := fetchEnv(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var env map[string]string
	err = json.Unmarshal(resp, &env)

	if err != nil {
		stdcli.Error(err)
		return
	}

	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])
	}
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:35,代码来源:env.go


示例3: cmdEnvUnset

func cmdEnvUnset(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(c.Args()) == 0 {
		stdcli.Error(errors.New("No variable specified"))
		return
	}

	if len(c.Args()) > 1 {
		stdcli.Error(errors.New("Only 1 variable can be unset at a time"))
		return
	}

	variable := c.Args()[0]

	path := fmt.Sprintf("/apps/%s/environment/%s", app, variable)

	_, err = ConvoxDelete(path)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:29,代码来源:env.go


示例4: cmdEnvUnset

func cmdEnvUnset(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}
	if len(c.Args()) == 1 {
		variable := c.Args()[0]

		path := fmt.Sprintf("/apps/%s/environment/%s", app, variable)

		_, err = ConvoxDelete(path)

		if err != nil {
			stdcli.Error(err)
			return
		}
	else {
		fmt.Printf("You supplied %d arguments to convox env unset, 1 is required\n", len(c.Args()))
	}
}

func fetchEnv(app string) ([]byte, error) {
	path := fmt.Sprintf("/apps/%s/environment", app)

	resp, err := ConvoxGet(path)

	if err != nil {
		return nil, err
	}

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


示例5: cmdBuilds

func cmdBuilds(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	path := fmt.Sprintf("/apps/%s/builds", app)

	resp, err := ConvoxGet(path)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var builds []Build

	err = json.Unmarshal(resp, &builds)

	if err != nil {
		stdcli.Error(err)
		return
	}

	fmt.Printf("%-12s  %-12s  %-9s  %-22s  %s\n", "ID", "RELEASE", "STATUS", "STARTED", "ENDED")

	for _, build := range builds {
		started := build.Started
		ended := build.Ended
		fmt.Printf("%-12s  %-12s  %-9s  %-22s  %s\n", build.Id, build.Release, build.Status, started.Format(time.RFC822Z), ended.Format(time.RFC822Z))
	}
}
开发者ID:noqcks,项目名称:cli,代码行数:34,代码来源:builds.go


示例6: cmdEnvGet

func cmdEnvGet(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}
	if len(c.Args()) == 1 {
		variable := c.Args()[0]

		resp, err := fetchEnv(app)

		if err != nil {
			stdcli.Error(err)
			return
		}

		var env map[string]string
		json.Unmarshal(resp, &env)

		fmt.Println(env[variable])
	} else {
        	fmt.Printf("You supplied %d arguments to convox env get, 1 is required\n", len(c.Args()))
        }
}
开发者ID:srri,项目名称:cli,代码行数:25,代码来源:env.go


示例7: cmdExec

func cmdExec(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(c.Args()) < 1 {
		stdcli.Usage(c, "exec")
		return
	}

	ps := c.Args()[0]

	command := ""

	if len(c.Args()) > 1 {
		args := c.Args()[1:]
		command = strings.Join(args, " ")
	}

	err = stdcli.Run("docker", "exec", "-it", fmt.Sprintf("%s-%s", app, ps), "sh", "-c", command)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:29,代码来源:exec.go


示例8: cmdRun

func cmdRun(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

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

	ps := c.Args()[0]

	command := ""

	if len(c.Args()) > 1 {
		args := c.Args()[1:]
		command = strings.Join(args, " ")
	}

	v := url.Values{}
	v.Set("command", command)

	_, err = ConvoxPostForm(fmt.Sprintf("/apps/%s/processes/%s/run", app, ps), v)

	if err != nil {
		stdcli.Error(err)
		return
	}

	fmt.Printf("Running %s `%s`\n", ps, command)
}
开发者ID:ngotnghet,项目名称:cli,代码行数:34,代码来源:run.go


示例9: cmdBuildsInfo

func cmdBuildsInfo(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(c.Args()) != 1 {
		stdcli.Usage(c, "info")
		return
	}

	build := c.Args()[0]

	path := fmt.Sprintf("/apps/%s/builds/%s", app, build)

	resp, err := ConvoxGet(path)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var b Build

	err = json.Unmarshal(resp, &b)

	if err != nil {
		stdcli.Error(err)
		return
	}

	fmt.Println(b.Logs)
}
开发者ID:noqcks,项目名称:cli,代码行数:35,代码来源:builds.go


示例10: cmdEnvGet

func cmdEnvGet(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(c.Args()) == 0 {
		stdcli.Error(errors.New("No variable specified"))
		return
	}

	if len(c.Args()) > 1 {
		stdcli.Error(errors.New("Only 1 variable can be retrieved at a time"))
		return
	}

	variable := c.Args()[0]

	resp, err := fetchEnv(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var env map[string]string
	json.Unmarshal(resp, &env)

	fmt.Println(env[variable])
}
开发者ID:redbadger,项目名称:cli,代码行数:32,代码来源:env.go


示例11: cmdPs

func cmdPs(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(c.Args()) == 0 {
		processList(app)
	} else {
		processTop(app, c.Args()[0])
	}
}
开发者ID:ngotnghet,项目名称:cli,代码行数:14,代码来源:ps.go


示例12: cmdReleases

func cmdReleases(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	data, err := ConvoxGet("/apps/" + app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var a *App
	err = json.Unmarshal(data, &a)

	data, err = ConvoxGet(fmt.Sprintf("/apps/%s/releases", a.Name))

	if err != nil {
		stdcli.Error(err)
		return
	}

	var releases *Releases
	err = json.Unmarshal(data, &releases)

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("ID", "CREATED", "ACTIVE")

	for _, r := range *releases {
		active := ""
		if a.Parameters["Release"] == r.Id {
			active = "yes"
		}

		t.AddRow(r.Id, humanize.Time(r.Created), active)
	}

	t.Print()
}
开发者ID:2opremio,项目名称:cli,代码行数:46,代码来源:releases.go


示例13: cmdScale

func cmdScale(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	v := url.Values{}

	if c.IsSet("count") {
		v.Set("count", c.String("count"))
	}

	if c.IsSet("memory") {
		v.Set("mem", c.String("memory"))
	}

	if len(v) > 0 {
		_, err = ConvoxPostForm("/apps/"+app, v)

		if err != nil {
			stdcli.Error(err)
			return
		}
	}

	data, err := ConvoxGet("/apps/" + app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var a *App
	err = json.Unmarshal(data, &a)

	if err != nil {
		stdcli.Error(err)
		return
	}

	fmt.Printf("Count %v\n", a.Parameters["DesiredCount"])
	fmt.Printf("Memory %v\n", a.Parameters["Memory"])
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:45,代码来源:scale.go


示例14: cmdEnvUnset

func cmdEnvUnset(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	variable := c.Args()[0]

	path := fmt.Sprintf("/apps/%s/environment/%s", app, variable)

	_, err = ConvoxDelete(path)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:rjocoleman,项目名称:cli,代码行数:19,代码来源:env.go


示例15: cmdDebug

func cmdDebug(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	data, err := ConvoxGet(fmt.Sprintf("/apps/%s/events", app))

	if err != nil {
		stdcli.Error(err)
		return
	}

	lines := strings.Split(string(data), "\n")
	for i := len(lines) - 1; i >= 0; i-- {
		fmt.Printf("%v\n", lines[i])
	}
}
开发者ID:ngotnghet,项目名称:cli,代码行数:20,代码来源:debug.go


示例16: cmdBuild

func cmdBuild(c *cli.Context) {
	wd := "."

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

	dir, app, err := stdcli.DirApp(c, wd)

	if err != nil {
		stdcli.Error(err)
		return
	}

	_, err = executeBuild(dir, app)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:ngotnghet,项目名称:cli,代码行数:21,代码来源:build.go


示例17: cmdEnvGet

func cmdEnvGet(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	variable := c.Args()[0]

	resp, err := fetchEnv(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	var env map[string]string
	json.Unmarshal(resp, &env)

	fmt.Println(env[variable])
}
开发者ID:rjocoleman,项目名称:cli,代码行数:22,代码来源:env.go


示例18: cmdReleasePromote

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

	release := c.Args()[0]

	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	_, err = postRelease(app, release)

	if err != nil {
		stdcli.Error(err)
		return
	}
}
开发者ID:noqcks,项目名称:cli,代码行数:22,代码来源:releases.go


示例19: cmdReleaseInfo

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

	release := c.Args()[0]

	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	data, err := ConvoxGet(fmt.Sprintf("/apps/%s/releases/%s", app, release))

	if err != nil {
		stdcli.Error(err)
		return
	}

	var r Release

	err = json.Unmarshal(data, &r)

	if err != nil {
		stdcli.Error(err)
		return
	}

	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))
}
开发者ID:noqcks,项目名称:cli,代码行数:37,代码来源:releases.go


示例20: cmdPs

func cmdPs(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	data, err := ConvoxGet(fmt.Sprintf("/apps/%s/processes", app))

	if err != nil {
		stdcli.Error(err)
		return
	}

	var processes *Processes
	err = json.Unmarshal(data, &processes)

	if err != nil {
		stdcli.Error(err)
		return
	}

	longest := 7

	for _, ps := range *processes {
		if len(ps.Name) > longest {
			longest = len(ps.Name)
		}
	}

	fmt.Printf(fmt.Sprintf("%%-12s  %%-%ds  %%-11s  %%-5s  %%s\n", longest), "ID", "PROCESS", "RELEASE", "MEM", "COMMAND")

	for _, ps := range *processes {
		fmt.Printf(fmt.Sprintf("%%-12s  %%-%ds  %%-11s  %%-5d  %%s\n", longest), ps.Id, ps.Name, ps.Release, ps.Memory, ps.Command)
	}
}
开发者ID:oren,项目名称:cli,代码行数:37,代码来源:ps.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang stdcli.Error函数代码示例发布时间:2022-05-23
下一篇:
Golang cli.Context类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap