diff options
| -rw-r--r-- | drive/list.go | 15 | ||||
| -rw-r--r-- | gdrive.go | 6 | ||||
| -rw-r--r-- | handlers_drive.go | 1 | 
3 files changed, 21 insertions, 1 deletions
| diff --git a/drive/list.go b/drive/list.go index e636585..73fdea5 100644 --- a/drive/list.go +++ b/drive/list.go @@ -17,12 +17,13 @@ type ListFilesArgs struct {      SortOrder string      SkipHeader bool      SizeInBytes bool +    AbsPath bool  }  func (self *Drive) List(args ListFilesArgs) (err error) {      listArgs := listAllFilesArgs{          query: args.Query, -        fields: []googleapi.Field{"nextPageToken", "files(id,name,md5Checksum,mimeType,size,createdTime)"}, +        fields: []googleapi.Field{"nextPageToken", "files(id,name,md5Checksum,mimeType,size,createdTime,parents)"},          sortOrder: args.SortOrder,          maxFiles: args.MaxFiles,      } @@ -31,6 +32,18 @@ func (self *Drive) List(args ListFilesArgs) (err error) {          return fmt.Errorf("Failed to list files: %s", err)      } +    pathfinder := self.newPathfinder() + +    if args.AbsPath { +        // Replace name with absolute path +        for _, f := range files { +            f.Name, err = pathfinder.absPath(f) +            if err != nil { +                return err +            } +        } +    } +      PrintFileList(PrintFileListArgs{          Out: args.Out,          Files: files, @@ -72,6 +72,12 @@ func main() {                          DefaultValue: DefaultNameWidth,                      },                      cli.BoolFlag{ +                        Name: "absPath", +                        Patterns: []string{"--absolute"}, +                        Description: "Show absolute path to file (will only show path from first parent)", +                        OmitValue: true, +                    }, +                    cli.BoolFlag{                          Name: "skipHeader",                          Patterns: []string{"--no-header"},                          Description: "Dont print the header", diff --git a/handlers_drive.go b/handlers_drive.go index 3698d0e..05b1ca9 100644 --- a/handlers_drive.go +++ b/handlers_drive.go @@ -28,6 +28,7 @@ func listHandler(ctx cli.Context) {          SortOrder: args.String("sortOrder"),          SkipHeader: args.Bool("skipHeader"),          SizeInBytes: args.Bool("sizeInBytes"), +        AbsPath: args.Bool("absPath"),      })      checkErr(err)  } | 
