Exemplo n.º 1
0
func TestCat(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteBoth("file1", "aaa", t1)
	file2 := r.WriteBoth("file2", "bbb", t2)

	fstest.CheckItems(t, r.fremote, file1, file2)

	var buf bytes.Buffer
	err := fs.Cat(r.fremote, &buf)
	require.NoError(t, err)
	res := buf.String()

	if res != "aaabbb" && res != "bbbaaa" {
		t.Errorf("Incorrect output from Cat: %q", res)
	}
}
Exemplo n.º 2
0
Arquivo: cat.go Projeto: ncw/rclone
func init() {
	cmd.Root.AddCommand(commandDefintion)
}

var commandDefintion = &cobra.Command{
	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)
		cmd.Run(false, false, command, func() error {
			return fs.Cat(fsrc, os.Stdout)
		})
	},
}