MCPcopy Index your code
hub / github.com/peak/s5cmd / NewMakeBucketCommand

Function NewMakeBucketCommand

command/mb.go:32–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30`
31
32func 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.
71type MakeBucket struct {

Callers 1

CommandsFunction · 0.85

Calls 9

CollectFunction · 0.92
validateMBCommandFunction · 0.85
printErrorFunction · 0.85
commandFromContextFunction · 0.85
NewStorageOptsFunction · 0.85
parseArgumentToCompleteFunction · 0.85
BaseMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected