diff options
| author | s <[email protected]> | 2025-11-25 09:58:42 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-25 09:58:42 -0500 |
| commit | 8a342848809a26e7e13933180b4df91d4a52f898 (patch) | |
| tree | 6d273e54d6ffb6ae694e21ce587e28348b01aea5 /cmd/services.go | |
| parent | 8472267b60b204cea5fbdeaf8fe06443822d1bfb (diff) | |
| download | dborg-8a342848809a26e7e13933180b4df91d4a52f898.tar.gz dborg-8a342848809a26e7e13933180b4df91d4a52f898.zip | |
feat: add dns site check, services list, and additional twitter/x api endpointsv1.0.6
Diffstat (limited to 'cmd/services.go')
| -rw-r--r-- | cmd/services.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cmd/services.go b/cmd/services.go new file mode 100644 index 0000000..56c2149 --- /dev/null +++ b/cmd/services.go @@ -0,0 +1,49 @@ +package cmd + +import ( + "encoding/json" + "fmt" + + "github.com/spf13/cobra" +) + +var servicesCmd = &cobra.Command{ + Use: "services", + Short: "List all available services and pricing", + Long: `Get a list of all available services and their credit costs`, + RunE: runServices, +} + +func init() { + rootCmd.AddCommand(servicesCmd) +} + +func runServices(cmd *cobra.Command, args []string) error { + c, err := newUnauthenticatedClient() + if err != nil { + return err + } + + data, err := c.ListServices() + if err != nil { + return err + } + + if IsJSONOutput() { + fmt.Println(string(data)) + return nil + } + + var services map[string]interface{} + if err := json.Unmarshal(data, &services); err != nil { + return fmt.Errorf("failed to parse services: %w", err) + } + + fmt.Println("\nAvailable Services:") + fmt.Println("===================\n") + + servicesData, _ := json.MarshalIndent(services, "", " ") + fmt.Println(string(servicesData)) + + return nil +} |
