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

Function NewCatCommand

command/cat.go:36–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34`
35
36func 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 },

Callers 1

CommandsFunction · 0.85

Calls 12

CollectFunction · 0.92
NewFunction · 0.92
WithVersionFunction · 0.92
WithRawFunction · 0.92
validateCatCommandFunction · 0.85
printErrorFunction · 0.85
commandFromContextFunction · 0.85
NewStorageOptsFunction · 0.85
getBashCompleteFnFunction · 0.85
GetMethod · 0.45
StringMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected