diff options
Diffstat (limited to 'cmd/reddit.go')
| -rw-r--r-- | cmd/reddit.go | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/cmd/reddit.go b/cmd/reddit.go index 194fdab..5969f7c 100644 --- a/cmd/reddit.go +++ b/cmd/reddit.go @@ -5,8 +5,8 @@ import ( "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" "github.com/spf13/cobra" ) @@ -102,7 +102,12 @@ func runRedditSubredditPosts(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - return utils.PrintJSON(response) + output, err := formatter.FormatRedditResults(response, IsJSONOutput()) + if err != nil { + return err + } + fmt.Print(output) + return nil } func runRedditSubredditComments(cmd *cobra.Command, args []string) error { @@ -126,7 +131,12 @@ func runRedditSubredditComments(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - return utils.PrintJSON(response) + output, err := formatter.FormatRedditResults(response, IsJSONOutput()) + if err != nil { + return err + } + fmt.Print(output) + return nil } func runRedditUserPosts(cmd *cobra.Command, args []string) error { @@ -150,7 +160,12 @@ func runRedditUserPosts(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - return utils.PrintJSON(response) + output, err := formatter.FormatRedditResults(response, IsJSONOutput()) + if err != nil { + return err + } + fmt.Print(output) + return nil } func runRedditUserComments(cmd *cobra.Command, args []string) error { @@ -174,7 +189,12 @@ func runRedditUserComments(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - return utils.PrintJSON(response) + output, err := formatter.FormatRedditResults(response, IsJSONOutput()) + if err != nil { + return err + } + fmt.Print(output) + return nil } func runRedditUserAbout(cmd *cobra.Command, args []string) error { @@ -198,5 +218,10 @@ func runRedditUserAbout(cmd *cobra.Command, args []string) error { return fmt.Errorf("API error: %s", response.Error) } - return utils.PrintJSON(response) + output, err := formatter.FormatRedditResults(response, IsJSONOutput()) + if err != nil { + return err + } + fmt.Print(output) + return nil } |
