|
- package cmdline
-
- /*
- import (
- "fmt"
- "time"
-
- "github.com/jedib0t/go-pretty/v6/table"
- cdssdk "gitlink.org.cn/cloudream/jcs-pub/client/types"
- )
-
- func BucketListUserBuckets(ctx CommandContext) error {
-
- buckets, err := ctx.Cmdline.Svc.BucketSvc().GetUserBuckets()
- if err != nil {
- return err
- }
-
- fmt.Printf("Find %d buckets for user %d:\n", len(buckets))
-
- tb := table.NewWriter()
- tb.AppendHeader(table.Row{"ID", "Name"})
-
- for _, bucket := range buckets {
- tb.AppendRow(table.Row{bucket.BucketID, bucket.Name})
- }
-
- fmt.Print(tb.Render())
- return nil
- }
-
- func BucketCreateBucket(ctx CommandContext, bucketName string) error {
- bucketID, err := ctx.Cmdline.Svc.BucketSvc().CreateBucket(bucketName, time.Now())
- if err != nil {
- return err
- }
-
- fmt.Printf("Create bucket %v success, id: %v", bucketName, bucketID)
- return nil
- }
-
- func BucketDeleteBucket(ctx CommandContext, bucketID cdssdk.BucketID) error {
-
- err := ctx.Cmdline.Svc.BucketSvc().DeleteBucket(bucketID)
- if err != nil {
- return err
- }
-
- fmt.Printf("Delete bucket %d success ", bucketID)
- return nil
- }
-
- func init() {
- commands.MustAdd(BucketListUserBuckets, "bucket", "ls")
-
- commands.MustAdd(BucketCreateBucket, "bucket", "new")
-
- commands.MustAdd(BucketDeleteBucket, "bucket", "delete")
- }
- */
|