2021-03-31 16:56:34 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zeebo/clingy"
|
2021-05-05 22:53:08 +01:00
|
|
|
"github.com/zeebo/errs"
|
2021-03-31 16:56:34 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type cmdMb struct {
|
|
|
|
projectProvider
|
|
|
|
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cmdMb) Setup(a clingy.Arguments, f clingy.Flags) {
|
|
|
|
c.projectProvider.Setup(a, f)
|
|
|
|
|
|
|
|
c.name = a.New("name", "Bucket name (sj://BUCKET)").(string)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cmdMb) Execute(ctx clingy.Context) error {
|
2021-05-05 22:53:08 +01:00
|
|
|
project, err := c.OpenProject(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return errs.Wrap(err)
|
|
|
|
}
|
|
|
|
defer func() { _ = project.Close() }()
|
|
|
|
|
|
|
|
_, err = project.CreateBucket(ctx, c.name)
|
|
|
|
return err
|
2021-03-31 16:56:34 +01:00
|
|
|
}
|