refactor: move cmd handlers to cmd/cli/commands/ following tag_file architecture
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user