func checkFilter(appName string, filter string) error { if filter != "" { processes, err := api.AppsPs(appName) if err != nil { return errgo.Mask(err) } filters := strings.Split(filter, "|") for _, f := range filters { ctName := "" for _, ct := range processes { ctName = ct.Name if strings.HasPrefix(f, ctName+"-") || f == ctName { break } } if !strings.HasPrefix(f, ctName+"-") && f != ctName { return errgo.Newf( "%s is not a valid container filter\n\nEXAMPLES:\n"+ "\"scalingo logs -F web\": logs of every web containers\n"+ "\"scalingo logs -F web-1\": logs of web container 1\n"+ "\"scalingo logs -F web|worker\": logs of every web and worker containers\n", f) } } } return nil }
func ScaleAutoComplete(c *cli.Context) error { appName := CurrentAppCompletion(c) if appName == "" { return nil } processes, err := api.AppsPs(appName) if err != nil { return errgo.Mask(err) } for _, ct := range processes { fmt.Println(fmt.Sprintf("%s:%d:%s", ct.Name, ct.Amount, ct.Size)) } return nil }
func Ps(app string) error { processes, err := api.AppsPs(app) if err != nil { return errgo.Mask(err) } t := tablewriter.NewWriter(os.Stdout) t.SetHeader([]string{"Name", "Amount", "Size", "Command"}) for _, ct := range processes { amount := fmt.Sprintf("%d", ct.Amount) if ct.Command != "" { t.Append([]string{ct.Name, amount, ct.Size, "`" + ct.Command + "`"}) } else { t.Append([]string{ct.Name, amount, ct.Size, "-"}) } } t.Render() return nil }