From 344a6f6415c3c1b593677adec3b8844e0839971b Mon Sep 17 00:00:00 2001 From: s Date: Thu, 13 Nov 2025 14:43:15 -0500 Subject: created pretty printing for all commands --- cmd/reddit.go | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'cmd/reddit.go') 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 } -- cgit v1.2.3