Add -q to list to print only container IDs
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d1e0015032
commit
852d20b0c6
11
list.go
11
list.go
|
@ -47,6 +47,10 @@ in json format:
|
||||||
|
|
||||||
# runc list -f json`,
|
# runc list -f json`,
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "quiet, q",
|
||||||
|
Usage: "display only container IDs",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(context *cli.Context) {
|
Action: func(context *cli.Context) {
|
||||||
s, err := getContainers(context)
|
s, err := getContainers(context)
|
||||||
|
@ -54,6 +58,13 @@ in json format:
|
||||||
fatal(err)
|
fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if context.Bool("quiet") {
|
||||||
|
for _, item := range s {
|
||||||
|
fmt.Println(item.ID)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch context.String("format") {
|
switch context.String("format") {
|
||||||
case "", "table":
|
case "", "table":
|
||||||
w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
|
||||||
|
|
|
@ -12,3 +12,4 @@ in json format:
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
--format, -f select one of: table or json.
|
--format, -f select one of: table or json.
|
||||||
|
--quiet, -q display only container IDs
|
||||||
|
|
Loading…
Reference in New Issue