()
| 30 | ` |
| 31 | |
| 32 | func NewMakeBucketCommand() *cli.Command { |
| 33 | cmd := &cli.Command{ |
| 34 | Name: "mb", |
| 35 | HelpName: "mb", |
| 36 | Usage: "make bucket", |
| 37 | CustomHelpTemplate: makeBucketHelpTemplate, |
| 38 | Before: func(c *cli.Context) error { |
| 39 | err := validateMBCommand(c) |
| 40 | if err != nil { |
| 41 | printError(commandFromContext(c), c.Command.Name, err) |
| 42 | } |
| 43 | return err |
| 44 | }, |
| 45 | Action: func(c *cli.Context) (err error) { |
| 46 | defer stat.Collect(c.Command.FullName(), &err)() |
| 47 | |
| 48 | return MakeBucket{ |
| 49 | src: c.Args().First(), |
| 50 | op: c.Command.Name, |
| 51 | fullCommand: commandFromContext(c), |
| 52 | |
| 53 | storageOpts: NewStorageOpts(c), |
| 54 | }.Run(c.Context) |
| 55 | }, |
| 56 | } |
| 57 | cmd.BashComplete = func(ctx *cli.Context) { |
| 58 | arg := parseArgumentToComplete(ctx) |
| 59 | if strings.HasPrefix(arg, "-") { |
| 60 | cli.DefaultCompleteWithFlags(cmd)(ctx) |
| 61 | } else { |
| 62 | shell := filepath.Base(os.Getenv("SHELL")) |
| 63 | constantCompleteWithDefault(shell, arg, "s3://") |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return cmd |
| 68 | } |
| 69 | |
| 70 | // MakeBucket holds bucket creation operation flags and states. |
| 71 | type MakeBucket struct { |
no test coverage detected