aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ls.go
diff options
context:
space:
mode:
authorvince <vincetiu8@gmail.com>2020-06-21 13:51:48 +0800
committervince <vincetiu8@gmail.com>2020-06-21 13:51:48 +0800
commitcd8352edde7f4a26cb6b4dd922b05aa0bb23a70b (patch)
tree1ac2cf77cd24310350fe58cb358cb82d0b48da35 /commands/ls.go
parentf790083fb28ac0e68acddc9d5e7a709107a70bab (diff)
downloadgit-bug-cd8352edde7f4a26cb6b4dd922b05aa0bb23a70b.tar.gz
Add output formatting support to the 'show' and 'user ls' commands
This adds options to specify an output format for the commands in question. Supported formats are currently: - 'plain': plaintext, stripped of all colors - 'json': prints output as a json object
Diffstat (limited to 'commands/ls.go')
-rw-r--r--commands/ls.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/commands/ls.go b/commands/ls.go
index 68cb0cfc..41f48f91 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -72,7 +72,7 @@ func runLsBug(_ *cobra.Command, args []string) error {
}
}
-type JSONBug struct {
+type JSONBugExcerpt struct {
Id string `json:"id"`
HumanId string `json:"human_id"`
CreationTime time.Time `json:"creation_time"`
@@ -89,17 +89,10 @@ type JSONBug struct {
Metadata map[string]string `json:"metadata"`
}
-type JSONIdentity struct {
- Id string `json:"id"`
- HumanId string `json:"human_id"`
- Name string `json:"name"`
- Login string `json:"login"`
-}
-
func lsJsonFormatter(backend *cache.RepoCache, bugExcerpts []*cache.BugExcerpt) error {
- jsonBugs := make([]JSONBug, len(bugExcerpts))
+ jsonBugs := make([]JSONBugExcerpt, len(bugExcerpts))
for i, b := range bugExcerpts {
- jsonBug := JSONBug{
+ jsonBug := JSONBugExcerpt{
b.Id.String(),
b.Id.Human(),
time.Unix(b.CreateUnixTime, 0),
@@ -294,5 +287,5 @@ func init() {
lsCmd.Flags().StringVarP(&lsSortDirection, "direction", "d", "asc",
"Select the sorting direction. Valid values are [asc,desc]")
lsCmd.Flags().StringVarP(&lsOutputFormat, "format", "f", "default",
- "Select the output formatting style. Valid values are [default, plain(text), json]")
+ "Select the output formatting style. Valid values are [default,plain,json]")
}