Skip to content

Commit

Permalink
Add -q to list to print only container IDs
Browse files Browse the repository at this point in the history
Signed-off-by: Mrunal Patel <[email protected]>
  • Loading branch information
mrunalp committed Apr 14, 2016
1 parent d1e0015 commit 852d20b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@ in json format:
# runc list -f json`,
},
cli.BoolFlag{
Name: "quiet, q",
Usage: "display only container IDs",
},
},
Action: func(context *cli.Context) {
s, err := getContainers(context)
if err != nil {
fatal(err)
}

if context.Bool("quiet") {
for _, item := range s {
fmt.Println(item.ID)
}
return
}

switch context.String("format") {
case "", "table":
w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
Expand Down
1 change: 1 addition & 0 deletions man/runc-list.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ in json format:

# OPTIONS
--format, -f select one of: table or json.
--quiet, -q display only container IDs

0 comments on commit 852d20b

Please sign in to comment.