forked from toolshed/abra
Introduce a JSON output table mechanic
- Create JSONTable as a proxy/extension to tablewriter which can also output JSON. - Implement machine readable output for `server list` and `recipe list`
This commit is contained in:
@ -27,6 +27,7 @@ var recipeListCommand = cli.Command{
|
||||
Aliases: []string{"ls"},
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.MachineReadableFlag,
|
||||
patternFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
@ -66,10 +67,14 @@ var recipeListCommand = cli.Command{
|
||||
}
|
||||
}
|
||||
|
||||
table.SetCaption(true, fmt.Sprintf("total recipes: %v", len))
|
||||
|
||||
if table.NumLines() > 0 {
|
||||
table.Render()
|
||||
if internal.MachineReadable {
|
||||
table.SetCaption(false, "")
|
||||
table.JSONRender()
|
||||
} else {
|
||||
table.SetCaption(true, fmt.Sprintf("total recipes: %v", len))
|
||||
table.Render()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user