From 148eab7c04a6eddb439ddcdb0a3ba12d03bb625b Mon Sep 17 00:00:00 2001
From: Nick White <git@njw.name>
Date: Mon, 23 Mar 2020 10:45:59 +0000
Subject: [getpipelinebook] Add -graph flag to download just graphs

---
 cmd/getpipelinebook/main.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

(limited to 'cmd')

diff --git a/cmd/getpipelinebook/main.go b/cmd/getpipelinebook/main.go
index f0dd4cf..f1092f8 100644
--- a/cmd/getpipelinebook/main.go
+++ b/cmd/getpipelinebook/main.go
@@ -16,7 +16,7 @@ import (
 	"rescribe.xyz/bookpipeline"
 )
 
-const usage = `Usage: getpipelinebook [-a] [-pdf] [-png] [-v] bookname
+const usage = `Usage: getpipelinebook [-a] [-graph] [-pdf] [-png] [-v] bookname
 
 Downloads the pipeline results for a book.
 
@@ -56,7 +56,8 @@ func getpdfs(conn Pipeliner, l *log.Logger, bookname string) {
 
 func main() {
 	all := flag.Bool("a", false, "Get all files for book")
-	pdf := flag.Bool("pdf", false, "Only download PDFs")
+	graph := flag.Bool("graph", false, "Only download graphs (can be used alongside -pdf)")
+	pdf := flag.Bool("pdf", false, "Only download PDFs (can be used alongside -graph)")
 	png := flag.Bool("png", false, "Only download best binarised png files")
 	verbose := flag.Bool("v", false, "Verbose")
 	flag.Usage = func() {
@@ -113,6 +114,18 @@ func main() {
 
 	if *pdf {
 		getpdfs(conn, verboselog, bookname)
+	}
+
+	if *graph {
+		fn := filepath.Join(bookname, "graph.png")
+		verboselog.Println("Downloading file", fn)
+		err = conn.Download(conn.WIPStorageId(), fn, fn)
+		if err != nil {
+			log.Fatalln("Failed to download file", fn, err)
+		}
+	}
+
+	if *pdf || *graph {
 		return
 	}
 
-- 
cgit v1.2.1-24-ge1ad