2016-08-18 23:43:02 +02:00
|
|
|
package cat
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/ncw/rclone/cmd"
|
|
|
|
"github.com/ncw/rclone/fs"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2016-10-22 13:05:45 +02:00
|
|
|
cmd.Root.AddCommand(commandDefintion)
|
2016-08-18 23:43:02 +02:00
|
|
|
}
|
|
|
|
|
2016-10-22 13:05:45 +02:00
|
|
|
var commandDefintion = &cobra.Command{
|
2016-08-18 23:43:02 +02:00
|
|
|
Use: "cat remote:path",
|
|
|
|
Short: `Concatenates any files and sends them to stdout.`,
|
|
|
|
Long: `
|
|
|
|
rclone cat sends any files to standard output.
|
|
|
|
|
|
|
|
You can use it like this to output a single file
|
|
|
|
|
|
|
|
rclone cat remote:path/to/file
|
|
|
|
|
|
|
|
Or like this to output any file in dir or subdirectories.
|
|
|
|
|
|
|
|
rclone cat remote:path/to/dir
|
|
|
|
|
|
|
|
Or like this to output any .txt files in dir or subdirectories.
|
|
|
|
|
|
|
|
rclone --include "*.txt" cat remote:path/to/dir
|
|
|
|
`,
|
|
|
|
Run: func(command *cobra.Command, args []string) {
|
|
|
|
cmd.CheckArgs(1, 1, command, args)
|
|
|
|
fsrc := cmd.NewFsSrc(args)
|
2016-12-04 17:52:24 +01:00
|
|
|
cmd.Run(false, false, command, func() error {
|
2016-08-18 23:43:02 +02:00
|
|
|
return fs.Cat(fsrc, os.Stdout)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|