aboutsummaryrefslogtreecommitdiff
path: root/tprint/src/Options
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-03-01 08:43:47 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2016-03-01 08:43:47 +0100
commit6bd2bb7117e2b0d2932fdb683a307f91947c2e2b (patch)
treeac9f7e54af90990105d3cf3dbda61886d9ef0ecc /tprint/src/Options
parentb302f3442a4884029f1839d4dbb25e82358ee758 (diff)
downloadthermoprint-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.hs16
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
7import Options.Applicative 10import Options.Applicative
8 11
12import Data.Text (Text)
13import qualified Data.Text as T (pack)
14
9import Data.Char 15import Data.Char
10import Data.Maybe 16import Data.Maybe
11import Data.List 17import Data.List
@@ -13,7 +19,7 @@ import Text.Read
13 19
14import Data.Time 20import Data.Time
15 21
16import Thermoprint.Client (Range(..)) 22import Thermoprint.Client (Range(..), PrinterId(..), DraftId(..), DraftTitle)
17 23
18rCI :: (Read a, Show a) => ReadM a 24rCI :: (Read a, Show a) => ReadM a
19rCI = eitherReader rRep' 25rCI = 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
55pPrinter :: Mod OptionFields PrinterId -> Parser PrinterId
56pPrinter mod = option (PrinterId <$> auto) $ metavar "PRINTER" <> long "printer" <> short 'p' <> mod
57
58aDraft :: Parser DraftId
59aDraft = argument (DraftId <$> auto) (metavar "DRAFT")
60
61pTitle :: Parser DraftTitle
62pTitle = option (T.pack <$> auto) $ metavar "TITLE" <> long "title" <> short 't'