From fb1069b504e8cd37b9a2bcdccefa9699d0e1dee9 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 15 Dec 2020 12:37:43 +0000 Subject: [rmbook] Add -dryrun flag --- cmd/rmbook/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/rmbook/main.go b/cmd/rmbook/main.go index 8d434a9..c195d85 100644 --- a/cmd/rmbook/main.go +++ b/cmd/rmbook/main.go @@ -13,7 +13,7 @@ import ( "rescribe.xyz/bookpipeline" ) -const usage = `Usage: rmbook bookname +const usage = `Usage: rmbook [-dryrun] bookname Removes a book from cloud storage. ` @@ -33,6 +33,7 @@ type RmPipeliner interface { } func main() { + dryrun := flag.Bool("dryrun", false, "print which files would be deleted but don't delete") flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), usage) flag.PrintDefaults() @@ -68,6 +69,14 @@ func main() { log.Fatalln("No files found for book:", bookname) } + if *dryrun { + fmt.Printf("I would delete these files:\n") + for _, v := range objs { + fmt.Println(v) + } + return + } + fmt.Println("Deleting all files for book") err = conn.DeleteObjects(conn.WIPStorageId(), objs) if err != nil { -- cgit v1.2.1-24-ge1ad