From 6bd2bb7117e2b0d2932fdb683a307f91947c2e2b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 1 Mar 2016 08:43:47 +0100 Subject: Complete specification of cl arguments --- tprint/src/Options/Utils.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'tprint/src/Options') diff --git a/tprint/src/Options/Utils.hs b/tprint/src/Options/Utils.hs index 80b4a7e..2bb7fc6 100644 --- a/tprint/src/Options/Utils.hs +++ b/tprint/src/Options/Utils.hs @@ -2,10 +2,16 @@ module Options.Utils ( rCI , rTime , pRange + , pPrinter + , aDraft + , pTitle ) where import Options.Applicative +import Data.Text (Text) +import qualified Data.Text as T (pack) + import Data.Char import Data.Maybe import Data.List @@ -13,7 +19,7 @@ import Text.Read import Data.Time -import Thermoprint.Client (Range(..)) +import Thermoprint.Client (Range(..), PrinterId(..), DraftId(..), DraftTitle) rCI :: (Read a, Show a) => ReadM a rCI = eitherReader rRep' @@ -46,3 +52,11 @@ pRange r both min max = toRange <$> optional (option r (both <> min)) <*> option toRange Nothing (Just max) = Just $ Max max toRange (Just min) (Just max) = Just $ min `Through` max +pPrinter :: Mod OptionFields PrinterId -> Parser PrinterId +pPrinter mod = option (PrinterId <$> auto) $ metavar "PRINTER" <> long "printer" <> short 'p' <> mod + +aDraft :: Parser DraftId +aDraft = argument (DraftId <$> auto) (metavar "DRAFT") + +pTitle :: Parser DraftTitle +pTitle = option (T.pack <$> auto) $ metavar "TITLE" <> long "title" <> short 't' -- cgit v1.2.3