aboutsummaryrefslogtreecommitdiffstats
path: root/commands/user/user.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-12-29 12:49:12 +0100
committerMichael Muré <batolettre@gmail.com>2022-12-29 12:53:06 +0100
commit5844dd0a6a08f496e6018c0bad0b38d82a8846fc (patch)
treee0a22258e29c12bec617b18298bea6bb377aede6 /commands/user/user.go
parent211a038c6057c5cfdcbf4c7d4cc8b4e93d8dc8db (diff)
downloadgit-bug-5844dd0a6a08f496e6018c0bad0b38d82a8846fc.tar.gz
commands: share JSON creation
Diffstat (limited to 'commands/user/user.go')
-rw-r--r--commands/user/user.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/commands/user/user.go b/commands/user/user.go
index 9a1e477c..a9a45726 100644
--- a/commands/user/user.go
+++ b/commands/user/user.go
@@ -1,14 +1,12 @@
package usercmd
import (
- "encoding/json"
"fmt"
"github.com/spf13/cobra"
- json2 "github.com/MichaelMure/git-bug/commands/cmdjson"
-
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/commands/cmdjson"
"github.com/MichaelMure/git-bug/commands/completion"
"github.com/MichaelMure/git-bug/commands/execenv"
"github.com/MichaelMure/git-bug/util/colors"
@@ -78,12 +76,10 @@ func userDefaultFormatter(env *execenv.Env, users []*cache.IdentityExcerpt) erro
}
func userJsonFormatter(env *execenv.Env, users []*cache.IdentityExcerpt) error {
- jsonUsers := make([]json2.Identity, len(users))
+ jsonUsers := make([]cmdjson.Identity, len(users))
for i, user := range users {
- jsonUsers[i] = json2.NewIdentityFromExcerpt(user)
+ jsonUsers[i] = cmdjson.NewIdentityFromExcerpt(user)
}
- jsonObject, _ := json.MarshalIndent(jsonUsers, "", " ")
- env.Out.Printf("%s\n", jsonObject)
- return nil
+ return env.Out.PrintJSON(jsonUsers)
}