From f4dd433b66f7d25bca32df758e541c0eb948669b Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Sun, 17 Jan 2016 21:55:19 +0100 Subject: [PATCH] Implement delete --- drive/delete.go | 18 ++++++++++++++++++ handlers.go | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 drive/delete.go diff --git a/drive/delete.go b/drive/delete.go new file mode 100644 index 00000000..ebf72edc --- /dev/null +++ b/drive/delete.go @@ -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) +} diff --git a/handlers.go b/handlers.go index d74eb1a7..93250268 100644 --- a/handlers.go +++ b/handlers.go @@ -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) {