From 8d811536eb1b45e2be3eb6be1e2f1a3feef04336 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 1 Mar 2016 10:41:08 +0100 Subject: Option to block and wait for job to be printed --- tprint/src/Options.hs | 5 ++++- tprint/src/Options/Utils.hs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tprint/src/Options.hs b/tprint/src/Options.hs index 30350cb..ca5ee2b 100644 --- a/tprint/src/Options.hs +++ b/tprint/src/Options.hs @@ -44,6 +44,7 @@ data Operation } | JobCreate { printer :: Maybe PrinterId + , block :: Bool , input :: Input } | Job { jobId :: JobId } @@ -63,6 +64,7 @@ data Operation | DraftDelete { draftId :: DraftId } | DraftPrint { draftId :: DraftId + , block :: Bool , printer :: Maybe PrinterId } deriving (Show, Generic, PrettyVal) @@ -96,6 +98,7 @@ cmdJobs = info cmdJobs' $ progDesc "List printjobs" cmdJobCreate = info cmdJobCreate' $ progDesc "Queue a new job" where cmdJobCreate' = JobCreate <$> optional (pPrinter $ help "Direct for the job to printed on #PRINTER specifically") + <*> pBlock <*> pInput cmdJob = info cmdJob' $ progDesc "Retrieve a jobs contents" @@ -123,7 +126,7 @@ cmdDraftDelete = info cmdDraftDelete' $ progDesc "Delete a draft" where cmdDraftDelete' = DraftDelete <$> aDraft cmdDraftPrint = info cmdDraftPrint' $ progDesc "Queue a copy of a drafts contents to be printed" - where cmdDraftPrint' = DraftPrint <$> aDraft <*> optional (pPrinter $ help "Direct for the drafts contents to be printed on #PRINTER specifically") + where cmdDraftPrint' = DraftPrint <$> aDraft <*> pBlock <*> optional (pPrinter $ help "Direct for the drafts contents to be printed on #PRINTER specifically") pOperation :: Parser Operation pOperation = hsubparser $ mconcat [ command "printers" cmdPrinters diff --git a/tprint/src/Options/Utils.hs b/tprint/src/Options/Utils.hs index b3561e9..237aa56 100644 --- a/tprint/src/Options/Utils.hs +++ b/tprint/src/Options/Utils.hs @@ -5,6 +5,7 @@ module Options.Utils , pPrinter , aDraft , pTitle + , pBlock ) where import Options.Applicative @@ -60,3 +61,6 @@ aDraft = argument (DraftId <$> auto) (metavar "DRAFT") pTitle :: Parser DraftTitle pTitle = option (T.pack <$> auto) $ metavar "TITLE" <> long "title" <> short 't' + +pBlock :: Parser Bool +pBlock = switch $ long "block" <> short 'b' <> help "Do not return until job has finished printing or failed. Report errors during printing" -- cgit v1.2.3