本文整理汇总了Golang中github.com/convox/rack/Godeps/_workspace/src/github.com/codegangsta/cli.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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.")
}
开发者ID:kuenzaa,项目名称:rack,代码行数:33,代码来源:ssl.go
示例2: cmdPsInfo
func cmdPsInfo(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
}
id := c.Args()[0]
p, err := rackClient(c).GetProcess(app, id)
if err != nil {
stdcli.Error(err)
return
}
fmt.Printf("Id %s\n", p.Id)
fmt.Printf("Name %s\n", p.Name)
fmt.Printf("Release %s\n", p.Release)
fmt.Printf("Size %d\n", p.Size)
fmt.Printf("CPU %0.2f%%\n", p.Cpu)
fmt.Printf("Memory %0.2f%%\n", p.Memory*100)
fmt.Printf("Started %s\n", humanizeTime(p.Started))
fmt.Printf("Command %s\n", p.Command)
}
开发者ID:soulware,项目名称:rack,代码行数:31,代码来源:ps.go
示例3: 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
}
fmt.Printf("Promoting %s... ", release)
_, err = rackClient(c).PromoteRelease(app, release)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("UPDATING")
}
开发者ID:inconshreveable,项目名称:rack,代码行数:26,代码来源:releases.go
示例4: cmdInit
func cmdInit(c *cli.Context) {
wd := "."
if len(c.Args()) > 0 {
wd = c.Args()[0]
}
dir, _, err := stdcli.DirApp(c, wd)
if err != nil {
stdcli.Error(err)
return
}
changed, err := manifest.Init(dir)
if err != nil {
stdcli.Error(err)
return
}
if len(changed) > 0 {
fmt.Printf("Generated: %s\n", strings.Join(changed, ", "))
}
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:25,代码来源:start.go
示例5: cmdPs
func cmdPs(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
ps, err := rackClient(c).GetProcesses(app, c.Bool("stats"))
if err != nil {
stdcli.Error(err)
return
}
if c.Bool("stats") {
t := stdcli.NewTable("ID", "NAME", "RELEASE", "SIZE", "CPU", "MEM", "STARTED", "COMMAND")
for _, p := range ps {
t.AddRow(prettyId(p), p.Name, p.Release, fmt.Sprintf("%d", p.Size), fmt.Sprintf("%0.2f%%", p.Cpu), fmt.Sprintf("%0.2f%%", p.Memory*100), humanizeTime(p.Started), p.Command)
}
t.Print()
} else {
t := stdcli.NewTable("ID", "NAME", "RELEASE", "SIZE", "STARTED", "COMMAND")
for _, p := range ps {
t.AddRow(prettyId(p), p.Name, p.Release, fmt.Sprintf("%d", p.Size), humanizeTime(p.Started), p.Command)
}
t.Print()
}
}
开发者ID:soulware,项目名称:rack,代码行数:33,代码来源:ps.go
示例6: 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")
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:28,代码来源:apps.go
示例7: cmdPsStop
func cmdPsStop(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) != 1 {
stdcli.Usage(c, "stop")
return
}
id := c.Args()[0]
fmt.Printf("Stopping %s... ", id)
_, err = rackClient(c).StopProcess(app, id)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("OK")
}
开发者ID:soulware,项目名称:rack,代码行数:26,代码来源:ps.go
示例8: cmdRackParamsSet
func cmdRackParamsSet(c *cli.Context) {
system, err := rackClient(c).GetSystem()
if err != nil {
stdcli.Error(err)
return
}
params := map[string]string{}
for _, arg := range c.Args() {
parts := strings.SplitN(arg, "=", 2)
if len(parts) != 2 {
stdcli.Error(fmt.Errorf("invalid argument: %s", arg))
return
}
params[parts[0]] = parts[1]
}
fmt.Print("Updating parameters... ")
err = rackClient(c).SetParameters(system.Name, params)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("OK")
}
开发者ID:soulware,项目名称:rack,代码行数:32,代码来源:rack.go
示例9: executeBuildDir
func executeBuildDir(c *cli.Context, dir, app, manifest, description string) (string, error) {
dir, err := filepath.Abs(dir)
if err != nil {
return "", err
}
fmt.Print("Creating tarball... ")
tar, err := createTarball(dir)
if err != nil {
return "", err
}
fmt.Println("OK")
cache := !c.Bool("no-cache")
fmt.Print("Uploading... ")
build, err := rackClient(c).CreateBuildSource(app, tar, cache, manifest, description)
if err != nil {
return "", err
}
fmt.Println("OK")
return finishBuild(c, app, build)
}
开发者ID:soulware,项目名称:rack,代码行数:31,代码来源:builds.go
示例10: 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))
}
开发者ID:inconshreveable,项目名称:rack,代码行数:29,代码来源:releases.go
示例11: 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)
}
开发者ID:soulware,项目名称:rack,代码行数:32,代码来源:scale.go
示例12: cmdEnvList
func cmdEnvList(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) > 0 {
stdcli.Error(fmt.Errorf("`convox env` does not take arguments. Perhaps you meant `convox env set`?"))
}
env, err := rackClient(c).GetEnvironment(app)
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:soulware,项目名称:rack,代码行数:31,代码来源:env.go
示例13: DirApp
// If user specifies the app's name from command line, then use it;
// if not, try to read the app name from .convox/app
// otherwise use the current working directory's name
func DirApp(c *cli.Context, wd string) (string, string, error) {
abs, err := filepath.Abs(wd)
if err != nil {
return "", "", err
}
app := c.String("app")
if app == "" {
app, err = ReadSetting("app")
if err != nil {
app = ""
}
}
if app == "" {
app = path.Base(abs)
}
app = strings.ToLower(app)
return abs, app, nil
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:28,代码来源:stdcli.go
示例14: cmdRackUpdate
func cmdRackUpdate(c *cli.Context) {
versions, err := version.All()
if err != nil {
stdcli.Error(err)
return
}
specified := "stable"
if len(c.Args()) > 0 {
specified = c.Args()[0]
}
version, err := versions.Resolve(specified)
if err != nil {
stdcli.Error(err)
return
}
system, err := rackClient(c).UpdateSystem(version.Version)
if err != nil {
stdcli.Error(err)
return
}
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)
}
开发者ID:davidcoallier,项目名称:rack-1,代码行数:34,代码来源:rack.go
示例15: cmdRackReleases
func cmdRackReleases(c *cli.Context) {
vs, err := version.All()
if err != nil {
return
}
selected := version.Versions{}
for _, v := range vs {
switch {
case !v.Published && c.Bool("unpublished"):
selected = append(selected, v)
case v.Published:
selected = append(selected, v)
}
}
sort.Sort(sort.Reverse(selected))
if len(selected) > 20 {
selected = selected[0:20]
}
for _, v := range selected {
fmt.Println(v.Version)
}
}
开发者ID:davidcoallier,项目名称:rack-1,代码行数:28,代码来源:rack.go
示例16: cmdServiceInfo
func cmdServiceInfo(c *cli.Context) {
if len(c.Args()) != 1 {
stdcli.Usage(c, "info")
return
}
name := c.Args()[0]
service, err := rackClient(c).GetService(name)
if err != nil {
stdcli.Error(err)
return
}
fmt.Printf("Name %s\n", service.Name)
fmt.Printf("Status %s\n", service.Status)
if service.Status == "failed" {
fmt.Printf("Reason %s\n", service.StatusReason)
}
if len(service.Exports) > 0 {
fmt.Printf("Exports\n")
for key, value := range service.Exports {
fmt.Printf(" %s: %s\n", key, value)
}
} else if service.URL != "" {
// NOTE: this branch is deprecated
fmt.Printf("URL %s\n", service.URL)
}
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:33,代码来源:services.go
示例17: readCredentials
func readCredentials(c *cli.Context) (creds *AwsCredentials, err error) {
// read credentials from ENV
creds = &AwsCredentials{
Access: os.Getenv("AWS_ACCESS_KEY_ID"),
Secret: os.Getenv("AWS_SECRET_ACCESS_KEY"),
Session: os.Getenv("AWS_SESSION_TOKEN"),
}
if os.Getenv("AWS_ENDPOINT_URL") != "" {
url := os.Getenv("AWS_ENDPOINT_URL")
defaults.DefaultConfig.Endpoint = &url
}
var inputCreds *AwsCredentials
if len(c.Args()) > 0 {
fileName := c.Args()[0]
inputCreds, err = readCredentialsFromFile(fileName)
} else if !terminal.IsTerminal(int(os.Stdin.Fd())) {
inputCreds, err = readCredentialsFromSTDIN()
}
if inputCreds != nil {
creds = inputCreds
}
if err != nil {
return nil, err
}
if creds.Access == "" || creds.Secret == "" {
reader := bufio.NewReader(os.Stdin)
fmt.Println(CredentialsMessage)
fmt.Print("AWS Access Key ID: ")
creds.Access, err = reader.ReadString('\n')
if err != nil {
return creds, err
}
fmt.Print("AWS Secret Access Key: ")
creds.Secret, err = reader.ReadString('\n')
if err != nil {
return creds, err
}
fmt.Println("")
}
creds.Access = strings.TrimSpace(creds.Access)
creds.Secret = strings.TrimSpace(creds.Secret)
creds.Session = strings.TrimSpace(creds.Session)
return
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:59,代码来源:install.go
示例18: cmdProxy
func cmdProxy(c *cli.Context) {
if len(c.Args()) == 0 {
stdcli.Usage(c, "proxy")
}
for _, arg := range c.Args() {
parts := strings.SplitN(arg, ":", 3)
var host string
var port, hostport int
switch len(parts) {
case 2:
host = parts[0]
p, err := strconv.Atoi(parts[1])
if err != nil {
stdcli.Error(err)
return
}
port = p
hostport = p
case 3:
host = parts[1]
p, err := strconv.Atoi(parts[0])
if err != nil {
stdcli.Error(err)
return
}
port = p
p, err = strconv.Atoi(parts[2])
if err != nil {
stdcli.Error(err)
return
}
hostport = p
default:
stdcli.Error(fmt.Errorf("invalid argument: %s", arg))
return
}
go proxy(port, host, hostport, rackClient(c))
}
// block forever
select {}
}
开发者ID:soulware,项目名称:rack,代码行数:55,代码来源:proxy.go
示例19: executeBuildUrl
func executeBuildUrl(c *cli.Context, url string, app string, config string) (string, error) {
cache := !c.Bool("no-cache")
build, err := rackClient(c).CreateBuildUrl(app, url, cache, config)
if err != nil {
return "", err
}
return finishBuild(c, app, build)
}
开发者ID:anthonyrisinger,项目名称:rack,代码行数:11,代码来源:builds.go
示例20: executeBuildUrl
func executeBuildUrl(c *cli.Context, url, app, manifest, description string) (string, error) {
cache := !c.Bool("no-cache")
build, err := rackClient(c).CreateBuildUrl(app, url, cache, manifest, description)
if err != nil {
return "", err
}
return finishBuild(c, app, build)
}
开发者ID:soulware,项目名称:rack,代码行数:11,代码来源:builds.go
注:本文中的github.com/convox/rack/Godeps/_workspace/src/github.com/codegangsta/cli.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论