34 lines
579 B
Go
34 lines
579 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var billingCmd = &cobra.Command{
|
|
Use: "billing",
|
|
Short: "Billing and orders",
|
|
}
|
|
|
|
var 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)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
billingCmd.AddCommand(ordersCmd)
|
|
rootCmd.AddCommand(billingCmd)
|
|
}
|