ls.go 992 B

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