summaryrefslogtreecommitdiffstats
path: root/cmd/skiptrace.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/skiptrace.go')
-rw-r--r--cmd/skiptrace.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/cmd/skiptrace.go b/cmd/skiptrace.go
index 307204c..b8df9b4 100644
--- a/cmd/skiptrace.go
+++ b/cmd/skiptrace.go
@@ -2,12 +2,11 @@ package cmd
import (
"fmt"
+ "strconv"
+
"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"
- "strconv"
-
"github.com/spf13/cobra"
)
@@ -68,8 +67,7 @@ func init() {
}
func getSkiptraceClient(cmd *cobra.Command) (*client.Client, error) {
- cfg := config.New()
- return client.New(cfg)
+ return newClient()
}
func runSkiptracePeople(cmd *cobra.Command, args []string) error {
@@ -90,16 +88,15 @@ func runSkiptracePeople(cmd *cobra.Command, args []string) error {
return err
}
- if response.Error != "" {
- return fmt.Errorf("API error: %s", response.Error)
+ if err := checkError(response.Error); err != nil {
+ return err
}
- output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput())
+ output, err := formatter.FormatSkiptraceResults(*response, IsJSONOutput())
if err != nil {
return err
}
-
- fmt.Print(output)
+ printOutput(output)
return nil
}
@@ -120,16 +117,15 @@ func runSkiptraceReport(cmd *cobra.Command, args []string) error {
return err
}
- if response.Error != "" {
- return fmt.Errorf("API error: %s", response.Error)
+ if err := checkError(response.Error); err != nil {
+ return err
}
output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput())
if err != nil {
return err
}
-
- fmt.Print(output)
+ printOutput(output)
return nil
}
@@ -144,16 +140,15 @@ func runSkiptracePhone(cmd *cobra.Command, args []string) error {
return err
}
- if response.Error != "" {
- return fmt.Errorf("API error: %s", response.Error)
+ if err := checkError(response.Error); err != nil {
+ return err
}
output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput())
if err != nil {
return err
}
-
- fmt.Print(output)
+ printOutput(output)
return nil
}
@@ -168,15 +163,14 @@ func runSkiptraceEmail(cmd *cobra.Command, args []string) error {
return err
}
- if response.Error != "" {
- return fmt.Errorf("API error: %s", response.Error)
+ if err := checkError(response.Error); err != nil {
+ return err
}
output, err := formatter.FormatSkiptraceResults(response, IsJSONOutput())
if err != nil {
return err
}
-
- fmt.Print(output)
+ printOutput(output)
return nil
}