diff options
| -rw-r--r-- | drive/mkdir.go | 8 | ||||
| -rw-r--r-- | drive/upload.go | 8 | ||||
| -rw-r--r-- | gdrive.go | 8 | ||||
| -rw-r--r-- | handlers.go | 4 | 
4 files changed, 12 insertions, 16 deletions
| diff --git a/drive/mkdir.go b/drive/mkdir.go index 99047ee..8b3acc2 100644 --- a/drive/mkdir.go +++ b/drive/mkdir.go @@ -11,17 +11,15 @@ const DirectoryMimeType = "application/vnd.google-apps.folder"  type MkdirArgs struct {      Out io.Writer      Name string -    Parent string +    Parents []string      Share bool  }  func (self *Drive) Mkdir(args MkdirArgs) (err error) {      dstFile := &drive.File{Name: args.Name, MimeType: DirectoryMimeType} -    // Set parent folder if provided -    if args.Parent != "" { -        dstFile.Parents = []string{args.Parent} -    } +    // Set parent folders +    dstFile.Parents = args.Parents      // Create folder      f, err := self.service.Files.Create(dstFile).Do() diff --git a/drive/upload.go b/drive/upload.go index 3a65d0f..fdba5cc 100644 --- a/drive/upload.go +++ b/drive/upload.go @@ -14,7 +14,7 @@ type UploadFileArgs struct {      Out io.Writer      Path string      Name string -    Parent string +    Parents []string      Mime string      Recursive bool      Stdin bool @@ -53,10 +53,8 @@ func (self *Drive) Upload(args UploadFileArgs) (err error) {          dstFile.MimeType = args.Mime      } -    // Set parent folder if provided -    if args.Parent != "" { -        dstFile.Parents = []string{args.Parent} -    } +    // Set parent folders +    dstFile.Parents = args.Parents      f, err := self.service.Files.Create(dstFile).ResumableMedia(context.Background(), srcFile, srcFileInfo.Size(), dstFile.MimeType).Do()      if err != nil { @@ -109,10 +109,10 @@ func main() {                          Description: "Upload directory recursively",                          OmitValue: true,                      }, -                    cli.StringFlag{ +                    cli.StringSliceFlag{                          Name: "parent",                          Patterns: []string{"-p", "--parent"}, -                        Description: "Parent id, used to upload file to a specific directory", +                        Description: "Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents",                      },                      cli.StringFlag{                          Name: "name", @@ -168,10 +168,10 @@ func main() {              Flags: cli.Flags{                  "global options": globalFlags,                  "options": []cli.Flag{ -                    cli.StringFlag{ +                    cli.StringSliceFlag{                          Name: "parent",                          Patterns: []string{"-p", "--parent"}, -                        Description: "Parent id of created directory", +                        Description: "Parent id of created directory, can be specified multiple times to give many parents",                      },                      cli.BoolFlag{                          Name: "share", diff --git a/handlers.go b/handlers.go index f9775f7..5358c9b 100644 --- a/handlers.go +++ b/handlers.go @@ -45,7 +45,7 @@ func uploadHandler(ctx cli.Context) {          Out: os.Stdout,          Path: args.String("path"),          Name: args.String("name"), -        Parent: args.String("parent"), +        Parents: args.StringSlice("parent"),          Mime: args.String("mime"),          Recursive: args.Bool("recursive"),          Stdin: args.Bool("stdin"), @@ -69,7 +69,7 @@ func mkdirHandler(ctx cli.Context) {      err := newDrive(args).Mkdir(drive.MkdirArgs{          Out: os.Stdout,          Name: args.String("name"), -        Parent: args.String("parent"), +        Parents: args.StringSlice("parent"),          Share: args.Bool("share"),      })      checkErr(err) | 
