summaryrefslogtreecommitdiffstats
path: root/cmd/skiptrace.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/skiptrace.go')
-rw-r--r--cmd/skiptrace.go48
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
}