From 3372c864237d2bf18ccd18003db2f23645be3d18 Mon Sep 17 00:00:00 2001
From: Nick White <git@njw.name>
Date: Mon, 23 Mar 2020 11:10:34 +0000
Subject: [getpipelinebook] Add -binarisedpdf and -colourpdf flags

---
 cmd/getpipelinebook/main.go | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/cmd/getpipelinebook/main.go b/cmd/getpipelinebook/main.go
index f1092f8..5438255 100644
--- a/cmd/getpipelinebook/main.go
+++ b/cmd/getpipelinebook/main.go
@@ -57,6 +57,8 @@ func getpdfs(conn Pipeliner, l *log.Logger, bookname string) {
 func main() {
 	all := flag.Bool("a", false, "Get all files for book")
 	graph := flag.Bool("graph", false, "Only download graphs (can be used alongside -pdf)")
+	binarisedpdf := flag.Bool("binarisedpdf", false, "Only download binarised PDF (can be used alongside -graph)")
+	colourpdf := flag.Bool("colourpdf", false, "Only download colour PDF (can be used alongside -graph)")
 	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")
@@ -112,8 +114,22 @@ func main() {
 		return
 	}
 
-	if *pdf {
-		getpdfs(conn, verboselog, bookname)
+	if *binarisedpdf {
+		fn := filepath.Join(bookname, bookname + ".binarised.pdf")
+		verboselog.Println("Downloading file", fn)
+		err = conn.Download(conn.WIPStorageId(), fn, fn)
+		if err != nil {
+			log.Fatalln("Failed to download file", fn, err)
+		}
+	}
+
+	if *colourpdf {
+		fn := filepath.Join(bookname, bookname + ".colour.pdf")
+		verboselog.Println("Downloading file", fn)
+		err = conn.Download(conn.WIPStorageId(), fn, fn)
+		if err != nil {
+			log.Fatalln("Failed to download file", fn, err)
+		}
 	}
 
 	if *graph {
@@ -125,7 +141,11 @@ func main() {
 		}
 	}
 
-	if *pdf || *graph {
+	if *pdf {
+		getpdfs(conn, verboselog, bookname)
+	}
+
+	if *binarisedpdf || *colourpdf || *graph || *pdf {
 		return
 	}
 
-- 
cgit v1.2.1-24-ge1ad