Esempio n. 1
0
func TestLs(t *testing.T) {
	var buf bytes.Buffer
	err := fs.List(fremote, &buf)
	if err != nil {
		t.Fatalf("List failed: %v", err)
	}
	res := buf.String()
	if !strings.Contains(res, "        0 empty space\n") {
		t.Errorf("empty space missing: %q", res)
	}
	if !strings.Contains(res, "       60 potato2\n") {
		t.Errorf("potato2 missing: %q", res)
	}
}
Esempio n. 2
0
func TestLs(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1)
	file2 := r.WriteBoth("empty space", "", t2)

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

	var buf bytes.Buffer
	err := fs.List(r.fremote, &buf)
	require.NoError(t, err)
	res := buf.String()
	assert.Contains(t, res, "        0 empty space\n")
	assert.Contains(t, res, "       60 potato2\n")
}
Esempio n. 3
0
func TestLs(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1)
	file2 := r.WriteBoth("empty space", "", t2)

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

	var buf bytes.Buffer
	err := fs.List(r.fremote, &buf)
	if err != nil {
		t.Fatalf("List failed: %v", err)
	}
	res := buf.String()
	if !strings.Contains(res, "        0 empty space\n") {
		t.Errorf("empty space missing: %q", res)
	}
	if !strings.Contains(res, "       60 potato2\n") {
		t.Errorf("potato2 missing: %q", res)
	}
}
Esempio n. 4
0
        to speed it up. Since this can cause data loss, test first
        with the --dry-run flag.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.MoveDir(fdst, fsrc)
		},
		MinArgs: 2,
		MaxArgs: 2,
		Retry:   true,
	},
	{
		Name:     "ls",
		ArgsHelp: "[remote:path]",
		Help: `
        List all the objects in the the path with size and path.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.List(fdst, os.Stdout)
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
	{
		Name:     "lsd",
		ArgsHelp: "[remote:path]",
		Help: `
        List all directories/containers/buckets in the the path.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.ListDir(fdst, os.Stdout)
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
Esempio n. 5
0
package ls

import (
	"os"

	"github.com/ncw/rclone/cmd"
	"github.com/ncw/rclone/fs"
	"github.com/spf13/cobra"
)

func init() {
	cmd.Root.AddCommand(lsCmd)
}

var lsCmd = &cobra.Command{
	Use:   "ls remote:path",
	Short: `List all the objects in the the path with size and path.`,
	Run: func(command *cobra.Command, args []string) {
		cmd.CheckArgs(1, 1, command, args)
		fsrc := cmd.NewFsSrc(args)
		cmd.Run(false, command, func() error {
			return fs.List(fsrc, os.Stdout)
		})
	},
}
Esempio n. 6
0
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.Sync(fdst, fsrc, true)
			if err != nil {
				log.Fatalf("Failed to sync: %v", err)
			}
		},
		MinArgs: 2,
		MaxArgs: 2,
	},
	{
		Name:     "ls",
		ArgsHelp: "[remote:path]",
		Help: `
        List all the objects in the the path with size and path.`,
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.List(fdst, os.Stdout)
			if err != nil {
				log.Fatalf("Failed to list: %v", err)
			}
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
	{
		Name:     "lsd",
		ArgsHelp: "[remote:path]",
		Help: `
        List all directories/containers/buckets in the the path.`,
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.ListDir(fdst, os.Stdout)
			if err != nil {