()
| 34 | ` |
| 35 | |
| 36 | func NewCatCommand() *cli.Command { |
| 37 | cmd := &cli.Command{ |
| 38 | Name: "cat", |
| 39 | HelpName: "cat", |
| 40 | Usage: "print remote object content", |
| 41 | Flags: []cli.Flag{ |
| 42 | &cli.BoolFlag{ |
| 43 | Name: "raw", |
| 44 | Usage: "disable the wildcard operations, useful with filenames that contains glob characters", |
| 45 | }, |
| 46 | &cli.StringFlag{ |
| 47 | Name: "version-id", |
| 48 | Usage: "use the specified version of an object", |
| 49 | }, |
| 50 | &cli.IntFlag{ |
| 51 | Name: "concurrency", |
| 52 | Aliases: []string{"c"}, |
| 53 | Value: defaultCopyConcurrency, |
| 54 | Usage: "number of concurrent parts transferred between host and remote server", |
| 55 | }, |
| 56 | &cli.IntFlag{ |
| 57 | Name: "part-size", |
| 58 | Aliases: []string{"p"}, |
| 59 | Value: defaultPartSize, |
| 60 | Usage: "size of each part transferred between host and remote server, in MiB", |
| 61 | }, |
| 62 | }, |
| 63 | CustomHelpTemplate: catHelpTemplate, |
| 64 | Before: func(c *cli.Context) error { |
| 65 | err := validateCatCommand(c) |
| 66 | if err != nil { |
| 67 | printError(commandFromContext(c), c.Command.Name, err) |
| 68 | } |
| 69 | return err |
| 70 | }, |
| 71 | Action: func(c *cli.Context) (err error) { |
| 72 | defer stat.Collect(c.Command.FullName(), &err)() |
| 73 | |
| 74 | op := c.Command.Name |
| 75 | fullCommand := commandFromContext(c) |
| 76 | |
| 77 | src, err := url.New(c.Args().Get(0), url.WithVersion(c.String("version-id")), |
| 78 | url.WithRaw(c.Bool("raw"))) |
| 79 | if err != nil { |
| 80 | printError(fullCommand, op, err) |
| 81 | return err |
| 82 | } |
| 83 | |
| 84 | return Cat{ |
| 85 | src: src, |
| 86 | op: op, |
| 87 | fullCommand: fullCommand, |
| 88 | |
| 89 | storageOpts: NewStorageOpts(c), |
| 90 | concurrency: c.Int("concurrency"), |
| 91 | partSize: c.Int64("part-size") * megabytes, |
| 92 | }.Run(c.Context) |
| 93 | }, |
no test coverage detected