diff options
Diffstat (limited to 'cmd/me.go')
| -rw-r--r-- | cmd/me.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cmd/me.go b/cmd/me.go new file mode 100644 index 0000000..e5ba7ec --- /dev/null +++ b/cmd/me.go @@ -0,0 +1,41 @@ +package cmd + +import ( + "git.db.org.ai/dborg/internal/formatter" + "github.com/spf13/cobra" +) + +var meCmd = &cobra.Command{ + Use: "me", + Short: "Get account information and usage statistics", + Long: `Get your account information, credits, and usage statistics.`, + RunE: runMe, +} + +func init() { + rootCmd.AddCommand(meCmd) +} + +func runMe(cmd *cobra.Command, args []string) error { + c, err := newClient() + if err != nil { + return err + } + + response, err := c.GetAccountStats() + if err != nil { + return err + } + + if err := checkError(response.Error); err != nil { + return err + } + + output, err := formatter.FormatAccountStats(response, IsJSONOutput()) + if err != nil { + return err + } + + printOutput(output) + return nil +} |
