diff options
| author | s <[email protected]> | 2025-11-13 22:25:02 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-13 22:25:02 -0500 |
| commit | 07662d9403eb85b39e1ffcf91014bbf36efd1c5a (patch) | |
| tree | 1181435223899bae039a947c5fc4fdeec085f91b /cmd/skiptrace.go | |
| parent | 239936e87183a10a33ce593709eb16c92a04af98 (diff) | |
| download | dborg-07662d9403eb85b39e1ffcf91014bbf36efd1c5a.tar.gz dborg-07662d9403eb85b39e1ffcf91014bbf36efd1c5a.zip | |
refactor: break down large osint.go file into separate command modules and add helper functionsv1.0.1
Diffstat (limited to 'cmd/skiptrace.go')
| -rw-r--r-- | cmd/skiptrace.go | 38 |
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 } |
