本文整理汇总了Golang中github.com/convox/rack/Godeps/_workspace/src/github.com/codegangsta/cli.Context.Args方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Args方法的具体用法?Golang Context.Args怎么用?Golang Context.Args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/convox/rack/Godeps/_workspace/src/github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.Args方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cmdScale
func cmdScale(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) == 0 {
displayFormation(c, app)
return
}
process := c.Args()[0]
count := c.String("count")
memory := c.String("memory")
err = rackClient(c).SetFormation(app, process, count, memory)
if err != nil {
stdcli.Error(err)
return
}
displayFormation(c, app)
}
示例2: 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")
}
示例3: 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))
}
示例4: cmdRegistryAdd
func cmdRegistryAdd(c *cli.Context) {
if len(c.Args()) < 1 {
stdcli.Usage(c, "add")
return
}
server := c.Args()[0]
username := c.String("username")
password := c.String("password")
email := c.String("email")
if username == "" {
username = promptForUsername()
}
if password == "" {
password = promptForPassword()
}
_, err := rackClient(c).AddRegistry(server, username, password, email)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("Done.")
}
示例5: 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)
}
示例6: 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")
}
示例7: 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.")
}
示例8: 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)
}
}
示例9: 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])
}
}
示例10: 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")
}
示例11: 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, ", "))
}
}
示例12: 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")
}
示例13: 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)
}
示例14: 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
}
示例15: cmdDeploy
func cmdDeploy(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
}
fmt.Printf("Deploying %s\n", app)
a, err := rackClient(c).GetApp(app)
if err != nil {
stdcli.Error(err)
return
}
switch a.Status {
case "creating":
stdcli.Error(fmt.Errorf("app is still creating: %s", app))
return
case "running", "updating":
default:
stdcli.Error(fmt.Errorf("unable to build app: %s", app))
return
}
// build
release, err := executeBuild(c, dir, app, c.String("file"), c.String("description"))
if err != nil {
stdcli.Error(err)
return
}
if release == "" {
return
}
fmt.Printf("Promoting %s... ", release)
_, err = rackClient(c).PromoteRelease(app, release)
if err != nil {
stdcli.Error(err)
return
}
fmt.Println("UPDATING")
}