2025-03-20 22:14:45 +01:00

44 lines
810 B
Go

package main
import (
b2_client "backea/internal/client"
"context"
"fmt"
"os"
"time"
)
func main() {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// Create B2 client
client, err := b2_client.NewClientFromEnv()
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating B2 client: %v\n", err)
os.Exit(1)
}
// List buckets
buckets, err := client.ListBuckets(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error listing buckets: %v\n", err)
os.Exit(1)
}
// Print buckets
fmt.Println("B2 Buckets:")
fmt.Println("===========")
if len(buckets) == 0 {
fmt.Println("No buckets found")
} else {
for i, bucket := range buckets {
fmt.Printf("%d. %s (ID: %s)\n",
i+1,
bucket.Name,
bucket.ID)
}
}
}