summaryrefslogtreecommitdiffstats
path: root/cmd/x.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/x.go')
-rw-r--r--cmd/x.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/cmd/x.go b/cmd/x.go
index b933e3d..c88243b 100644
--- a/cmd/x.go
+++ b/cmd/x.go
@@ -5,6 +5,7 @@ import (
"fmt"
"git.db.org.ai/dborg/internal/client"
"git.db.org.ai/dborg/internal/config"
+ "git.db.org.ai/dborg/internal/utils"
"github.com/spf13/cobra"
)
@@ -56,19 +57,11 @@ func runXHistorySearch(cmd *cobra.Command, args []string) error {
}
if len(response.PreviousUsernames) > 0 {
- output, err := json.MarshalIndent(response.PreviousUsernames, "", " ")
- if err != nil {
- return fmt.Errorf("failed to format response: %w", err)
- }
- fmt.Println(string(output))
+ return utils.PrintJSON(response.PreviousUsernames)
} else if response.Response != "" {
fmt.Println(response.Response)
} else if response.Data != nil {
- output, err := json.MarshalIndent(response.Data, "", " ")
- if err != nil {
- return fmt.Errorf("failed to format response: %w", err)
- }
- fmt.Println(string(output))
+ return utils.PrintJSON(response.Data)
} else {
fmt.Println("No username history found")
}