diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 08:43:47 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 08:43:47 +0100 |
commit | 6bd2bb7117e2b0d2932fdb683a307f91947c2e2b (patch) | |
tree | ac9f7e54af90990105d3cf3dbda61886d9ef0ecc /tprint/src/Options | |
parent | b302f3442a4884029f1839d4dbb25e82358ee758 (diff) | |
download | thermoprint-6bd2bb7117e2b0d2932fdb683a307f91947c2e2b.tar thermoprint-6bd2bb7117e2b0d2932fdb683a307f91947c2e2b.tar.gz thermoprint-6bd2bb7117e2b0d2932fdb683a307f91947c2e2b.tar.bz2 thermoprint-6bd2bb7117e2b0d2932fdb683a307f91947c2e2b.tar.xz thermoprint-6bd2bb7117e2b0d2932fdb683a307f91947c2e2b.zip |
Complete specification of cl arguments
Diffstat (limited to 'tprint/src/Options')
-rw-r--r-- | tprint/src/Options/Utils.hs | 16 |
1 files changed, 15 insertions, 1 deletions
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 | |||
2 | ( rCI | 2 | ( rCI |
3 | , rTime | 3 | , rTime |
4 | , pRange | 4 | , pRange |
5 | , pPrinter | ||
6 | , aDraft | ||
7 | , pTitle | ||
5 | ) where | 8 | ) where |
6 | 9 | ||
7 | import Options.Applicative | 10 | import Options.Applicative |
8 | 11 | ||
12 | import Data.Text (Text) | ||
13 | import qualified Data.Text as T (pack) | ||
14 | |||
9 | import Data.Char | 15 | import Data.Char |
10 | import Data.Maybe | 16 | import Data.Maybe |
11 | import Data.List | 17 | import Data.List |
@@ -13,7 +19,7 @@ import Text.Read | |||
13 | 19 | ||
14 | import Data.Time | 20 | import Data.Time |
15 | 21 | ||
16 | import Thermoprint.Client (Range(..)) | 22 | import Thermoprint.Client (Range(..), PrinterId(..), DraftId(..), DraftTitle) |
17 | 23 | ||
18 | rCI :: (Read a, Show a) => ReadM a | 24 | rCI :: (Read a, Show a) => ReadM a |
19 | rCI = eitherReader rRep' | 25 | rCI = eitherReader rRep' |
@@ -46,3 +52,11 @@ pRange r both min max = toRange <$> optional (option r (both <> min)) <*> option | |||
46 | toRange Nothing (Just max) = Just $ Max max | 52 | toRange Nothing (Just max) = Just $ Max max |
47 | toRange (Just min) (Just max) = Just $ min `Through` max | 53 | toRange (Just min) (Just max) = Just $ min `Through` max |
48 | 54 | ||
55 | pPrinter :: Mod OptionFields PrinterId -> Parser PrinterId | ||
56 | pPrinter mod = option (PrinterId <$> auto) $ metavar "PRINTER" <> long "printer" <> short 'p' <> mod | ||
57 | |||
58 | aDraft :: Parser DraftId | ||
59 | aDraft = argument (DraftId <$> auto) (metavar "DRAFT") | ||
60 | |||
61 | pTitle :: Parser DraftTitle | ||
62 | pTitle = option (T.pack <$> auto) $ metavar "TITLE" <> long "title" <> short 't' | ||