Skip to content

Commit

Permalink
Implement delete
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen committed Jan 17, 2016
1 parent 1d1dd76 commit f4dd433
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions drive/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package drive

import (
"fmt"
)

type DeleteArgs struct {
Id string
}

func (self *Drive) Delete(args DeleteArgs) {
f, err := self.service.Files.Get(args.Id).Fields("name").Do()
errorF(err, "Failed to get file: %s", err)

err = self.service.Files.Delete(args.Id).Do()
errorF(err, "Failed to delete file")
fmt.Printf("Removed file '%s'\n", f.Name)
}
6 changes: 5 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ func urlHandler(ctx cli.Context) {
}

func deleteHandler(ctx cli.Context) {
fmt.Println("Deleting...")
args := ctx.Args()

newDrive(args).Delete(drive.DeleteArgs{
Id: args.String("id"),
})
}

func handler(ctx cli.Context) {
Expand Down

0 comments on commit f4dd433

Please sign in to comment.