package billing import ( "fmt" "git.yoresee.cc/nightstar/ry/internal/output" "git.yoresee.cc/nightstar/ry/internal/provider" "github.com/spf13/cobra" ) func Cmd(prov *provider.Provider, out **output.Printer) *cobra.Command { billingCmd := &cobra.Command{ Use: "billing", Short: "Billing and orders", } ordersCmd := &cobra.Command{ Use: "orders", Short: "List orders", RunE: func(cmd *cobra.Command, args []string) error { svc := (*prov).Billing() if svc == nil { return fmt.Errorf("billing not supported by current provider") } orders, err := svc.Orders(cmd.Context()) if err != nil { return err } return (*out).Print(orders) }, } billingCmd.AddCommand(ordersCmd) return billingCmd }