cmd/ctr: add quiet mode to ctr list
This is so I can delete all the containers I keep creating. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
ae502e8c2a
commit
0377bfda5d
@ -13,7 +13,14 @@ import (
|
|||||||
var listCommand = cli.Command{
|
var listCommand = cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "list containers",
|
Usage: "list containers",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "quiet, q",
|
||||||
|
Usage: "print only the container id",
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
|
quiet := context.Bool("quiet")
|
||||||
containers, err := getExecutionService(context)
|
containers, err := getExecutionService(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -22,6 +29,12 @@ var listCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if quiet {
|
||||||
|
for _, c := range response.Containers {
|
||||||
|
fmt.Println(c.ID)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
w := tabwriter.NewWriter(os.Stdout, 10, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 10, 1, 3, ' ', 0)
|
||||||
fmt.Fprintln(w, "ID\tPID\tSTATUS")
|
fmt.Fprintln(w, "ID\tPID\tSTATUS")
|
||||||
for _, c := range response.Containers {
|
for _, c := range response.Containers {
|
||||||
@ -36,6 +49,8 @@ var listCommand = cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user