本文整理汇总了Golang中github.com/convox/rack/cmd/convox/stdcli.DirApp函数的典型用法代码示例。如果您正苦于以下问题:Golang DirApp函数的具体用法?Golang DirApp怎么用?Golang DirApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DirApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
key := c.Args()[0]
_, err = rackClient(c).DeleteEnvironment(app, key)
if err != nil {
stdcli.Error(err)
return
}
}
示例2: 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
}
r, err := rackClient(c).GetRelease(app, release)
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))
}
示例3: 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]
env, err := rackClient(c).GetEnvironment(app)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println(env[variable])
}
示例4: cmdAppCreate
func cmdAppCreate(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) > 0 {
app = c.Args()[0]
}
if app == "" {
stdcli.Error(fmt.Errorf("must specify an app name"))
return
}
fmt.Printf("Creating app %s... ", app)
_, err = rackClient(c).CreateApp(app)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("CREATING")
}
示例5: cmdSSLDelete
func cmdSSLDelete(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) != 1 {
stdcli.Usage(c, "delete")
return
}
target := c.Args()[0]
parts := strings.Split(target, ":")
if len(parts) != 2 {
stdcli.Error(fmt.Errorf("target must be process:port"))
return
}
fmt.Printf("Deleting SSL listener %s... ", target)
_, err = rackClient(c).DeleteSSL(app, parts[0], parts[1])
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("Done.")
}
示例6: cmdScale
func cmdScale(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
count := c.String("count")
memory := c.String("memory")
if len(c.Args()) == 0 && count == "" && memory == "" {
displayFormation(c, app)
return
}
if len(c.Args()) != 1 || (count == "" && memory == "") {
stdcli.Usage(c, "scale")
return
}
process := c.Args()[0]
err = rackClient(c).SetFormation(app, process, count, memory)
if err != nil {
stdcli.Error(err)
return
}
displayFormation(c, app)
}
示例7: 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
}
示例8: cmdBuilds
func cmdBuilds(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
builds, err := rackClient(c).GetBuilds(app)
if err != nil {
stdcli.Error(err)
return
}
t := stdcli.NewTable("ID", "STATUS", "RELEASE", "STARTED", "ELAPSED", "DESC")
for _, build := range builds {
started := humanizeTime(build.Started)
elapsed := stdcli.Duration(build.Started, build.Ended)
if build.Ended.IsZero() {
elapsed = ""
}
t.AddRow(build.Id, build.Status, build.Release, started, elapsed, build.Description)
}
t.Print()
}
示例9: cmdExec
func cmdExec(c *cli.Context) {
fd := os.Stdin.Fd()
stdinState, err := terminal.GetState(int(fd))
defer terminal.Restore(int(fd), stdinState)
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) < 2 {
stdcli.Usage(c, "exec")
return
}
ps := c.Args()[0]
code, err := rackClient(c).ExecProcessAttached(app, ps, strings.Join(c.Args()[1:], " "), os.Stdin, os.Stdout)
terminal.Restore(int(fd), stdinState)
if err != nil {
stdcli.Error(err)
return
}
os.Exit(code)
}
示例10: cmdPs
func cmdPs(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.ExitError(err)
}
ps, err := rackClient(c).GetProcesses(app, c.Bool("stats"))
if err != nil {
return stdcli.ExitError(err)
}
if c.Bool("stats") {
fm, err := rackClient(c).ListFormation(app)
if err != nil {
return stdcli.ExitError(err)
}
displayProcessesStats(ps, fm)
return nil
}
displayProcesses(ps)
return nil
}
示例11: cmdInit
func cmdInit(c *cli.Context) error {
ep := stdcli.QOSEventProperties{Start: time.Now()}
distinctId, err := currentId()
if err != nil {
stdcli.QOSEventSend("cli-init", distinctId, stdcli.QOSEventProperties{Error: err})
}
wd := "."
if len(c.Args()) > 0 {
wd = c.Args()[0]
}
dir, _, err := stdcli.DirApp(c, wd)
if err != nil {
return stdcli.QOSEventSend("cli-init", distinctId, stdcli.QOSEventProperties{Error: err})
}
// TODO parse the Dockerfile and build a docker-compose.yml
if exists("docker-compose.yml") {
return stdcli.Error(fmt.Errorf("Cannot initialize a project that already contains a docker-compose.yml"))
}
err = initApplication(dir)
if err != nil {
return stdcli.QOSEventSend("cli-init", distinctId, stdcli.QOSEventProperties{Error: err})
}
return stdcli.QOSEventSend("cli-init", distinctId, ep)
}
示例12: cmdRun
func cmdRun(c *cli.Context) error {
if c.Bool("detach") {
return cmdRunDetached(c)
}
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.Error(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.Error(err)
}
args := strings.Join(c.Args()[1:], " ")
release := c.String("release")
code, err := runAttached(c, app, ps, args, release)
if err != nil {
return stdcli.Error(err)
}
return cli.NewExitError("", code)
}
示例13: cmdBuildsInfo
func cmdBuildsInfo(c *cli.Context) error {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
return stdcli.Error(err)
}
if len(c.Args()) != 1 {
stdcli.Usage(c, "info")
return nil
}
build := c.Args()[0]
b, err := rackClient(c).GetBuild(app, build)
if err != nil {
return stdcli.Error(err)
}
fmt.Printf("Build %s\n", b.Id)
fmt.Printf("Status %s\n", b.Status)
fmt.Printf("Release %s\n", b.Release)
fmt.Printf("Description %s\n", b.Description)
fmt.Printf("Started %s\n", humanizeTime(b.Started))
fmt.Printf("Elapsed %s\n", stdcli.Duration(b.Started, b.Ended))
return nil
}
示例14: cmdBuildsCreate
func cmdBuildsCreate(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 = rackClient(c).GetApp(app)
if err != nil {
stdcli.Error(err)
return
}
release, err := executeBuild(c, dir, app)
if err != nil {
stdcli.Error(err)
return
}
fmt.Printf("Release: %s\n", release)
}
示例15: 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
}