summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-12-15 12:37:43 +0000
committerNick White <git@njw.name>2020-12-15 12:37:43 +0000
commitfb1069b504e8cd37b9a2bcdccefa9699d0e1dee9 (patch)
tree58cc7fed8082ff2316bb4572176b4a710042d7ba /cmd
parent9147e57a3a634ad303e8f1e7c456988996d5c75b (diff)
[rmbook] Add -dryrun flag
Diffstat (limited to 'cmd')
-rw-r--r--cmd/rmbook/main.go11
1 files changed, 10 insertions, 1 deletions
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 {