From a78b620220945ce15ab9965701ab5e7d39f314f1 Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 2 Oct 2019 12:53:41 +0100 Subject: Improve usage notice for booktopipeline --- bookpipeline/cmd/booktopipeline/main.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bookpipeline') diff --git a/bookpipeline/cmd/booktopipeline/main.go b/bookpipeline/cmd/booktopipeline/main.go index 296f2c2..6d9f146 100644 --- a/bookpipeline/cmd/booktopipeline/main.go +++ b/bookpipeline/cmd/booktopipeline/main.go @@ -4,6 +4,7 @@ package main import ( "flag" + "fmt" "log" "os" "path/filepath" @@ -14,6 +15,15 @@ import ( "github.com/aws/aws-sdk-go/service/sqs" ) +const usage = `Usage: booktopipeline [-prebinarised] [-v] bookdir [bookname] + +Uploads the book in bookdir to the S3 'inprogress' bucket and adds it +to the 'preprocess' SQS queue, or the 'wipeonly' queue if the +prebinarised flag is set. + +If bookname is omitted the last part of the bookdir is used. +` + // null writer to enable non-verbose logging to be discarded type NullWriter bool @@ -38,10 +48,15 @@ func (f fileWalk) Walk(path string, info os.FileInfo, err error) error { func main() { verbose := flag.Bool("v", false, "Verbose") wipeonly := flag.Bool("prebinarised", false, "Prebinarised: only preprocessing will be to wipe") - flag.Parse() + flag.Usage = func() { + fmt.Fprintf(flag.CommandLine.Output(), usage) + flag.PrintDefaults() + } + flag.Parse() if flag.NArg() < 1 { - log.Fatal("Usage: booktopipeline [-v] bookdir [bookname]\n\nUploads the book in bookdir to the S3 'inprogress' bucket and adds it to the 'preprocess' SQS queue\nIf bookname is omitted the last part of the bookdir is used\n") + flag.Usage() + return } bookdir := flag.Arg(0) -- cgit v1.2.1-24-ge1ad