github.com/xhghs/rclone@v1.51.1-0.20200430155106-e186a28cced8/cmd/ls/ls.go (about) 1 package ls 2 3 import ( 4 "context" 5 "os" 6 7 "github.com/rclone/rclone/cmd" 8 "github.com/rclone/rclone/cmd/ls/lshelp" 9 "github.com/rclone/rclone/fs/operations" 10 "github.com/spf13/cobra" 11 ) 12 13 func init() { 14 cmd.Root.AddCommand(commandDefinition) 15 } 16 17 var commandDefinition = &cobra.Command{ 18 Use: "ls remote:path", 19 Short: `List the objects in the path with size and path.`, 20 Long: ` 21 Lists the objects in the source path to standard output in a human 22 readable format with size and path. Recurses by default. 23 24 Eg 25 26 $ rclone ls swift:bucket 27 60295 bevajer5jef 28 90613 canole 29 94467 diwogej7 30 37600 fubuwic 31 32 ` + lshelp.Help, 33 Run: func(command *cobra.Command, args []string) { 34 cmd.CheckArgs(1, 1, command, args) 35 fsrc := cmd.NewFsSrc(args) 36 cmd.Run(false, false, command, func() error { 37 return operations.List(context.Background(), fsrc, os.Stdout) 38 }) 39 }, 40 }