summaryrefslogtreecommitdiffstats
path: root/cmd/reddit.go
diff options
context:
space:
mode:
authors <[email protected]>2025-11-13 14:43:15 -0500
committers <[email protected]>2025-11-13 14:43:15 -0500
commit344a6f6415c3c1b593677adec3b8844e0839971b (patch)
treeb05291ecdf21917b27e9e234eeb997c2706966d5 /cmd/reddit.go
parenta5fc01a03753c9a18ddeaf13610dd99b4b311b80 (diff)
downloaddborg-344a6f6415c3c1b593677adec3b8844e0839971b.tar.gz
dborg-344a6f6415c3c1b593677adec3b8844e0839971b.zip
created pretty printing for all commandsv1.0.0
Diffstat (limited to 'cmd/reddit.go')
-rw-r--r--cmd/reddit.go37
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
}