From 344a6f6415c3c1b593677adec3b8844e0839971b Mon Sep 17 00:00:00 2001 From: s Date: Thu, 13 Nov 2025 14:43:15 -0500 Subject: created pretty printing for all commands --- cmd/skiptrace.go | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'cmd/skiptrace.go') diff --git a/cmd/skiptrace.go b/cmd/skiptrace.go index 9ce1b4b..307204c 100644 --- a/cmd/skiptrace.go +++ b/cmd/skiptrace.go @@ -4,8 +4,8 @@ import ( "fmt" "git.db.org.ai/dborg/internal/client" "git.db.org.ai/dborg/internal/config" + "git.db.org.ai/dborg/internal/formatter" "git.db.org.ai/dborg/internal/models" - "git.db.org.ai/dborg/internal/utils" "strconv" "github.com/spf13/cobra" @@ -90,10 +90,16 @@ func runSkiptracePeople(cmd *cobra.Command, args []string) error { return err } - if response.Data != nil && len(response.Data) > 0 { - return utils.PrintJSON(response.Data) + if response.Error != "" { + return fmt.Errorf("API error: %s", response.Error) } + output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput()) + if err != nil { + return err + } + + fmt.Print(output) return nil } @@ -118,16 +124,12 @@ func runSkiptraceReport(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - if response.Data != nil && len(response.Data) > 0 { - if err := utils.PrintJSON(response.Data); err != nil { - return err - } - } - - if response.Message != "" { - fmt.Println(response.Message) + output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput()) + if err != nil { + return err } + fmt.Print(output) return nil } @@ -146,16 +148,12 @@ func runSkiptracePhone(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - if response.Data != nil && len(response.Data) > 0 { - if err := utils.PrintJSON(response.Data); err != nil { - return err - } - } - - if response.Message != "" { - fmt.Println(response.Message) + output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput()) + if err != nil { + return err } + fmt.Print(output) return nil } @@ -174,15 +172,11 @@ func runSkiptraceEmail(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - if response.Data != nil && len(response.Data) > 0 { - if err := utils.PrintJSON(response.Data); err != nil { - return err - } - } - - if response.Message != "" { - fmt.Println(response.Message) + output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput()) + if err != nil { + return err } + fmt.Print(output) return nil } -- cgit v1.2.3