diff options
| author | s <[email protected]> | 2025-11-13 14:43:15 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-13 14:43:15 -0500 |
| commit | 344a6f6415c3c1b593677adec3b8844e0839971b (patch) | |
| tree | b05291ecdf21917b27e9e234eeb997c2706966d5 /cmd/skiptrace.go | |
| parent | a5fc01a03753c9a18ddeaf13610dd99b4b311b80 (diff) | |
| download | dborg-344a6f6415c3c1b593677adec3b8844e0839971b.tar.gz dborg-344a6f6415c3c1b593677adec3b8844e0839971b.zip | |
created pretty printing for all commandsv1.0.0
Diffstat (limited to 'cmd/skiptrace.go')
| -rw-r--r-- | cmd/skiptrace.go | 48 |
1 files changed, 21 insertions, 27 deletions
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 } |
