period 0.1.0.6 → 0.1.0.7
raw patch · 2 files changed
+32/−17 lines, 2 filesdep +ansi-wl-pprintPVP ok
version bump matches the API change (PVP)
Dependencies added: ansi-wl-pprint
API changes (from Hackage documentation)
Files
- exec/period.hs +27/−13
- period.cabal +5/−4
exec/period.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE RecordWildCards #-} module Main where @@ -8,18 +9,32 @@ import qualified Data.Text.IO as T import Options.Applicative import Text.Period-+import Text.PrettyPrint.ANSI.Leijen (string) import Prelude main :: IO ()-main = execParser (info (helper <*> optParser) $ progDesc "period") >>= runCommand+main = execParser (info (helper <*> optParser) $ progDescDoc (Just $ string desc)) >>= runCommand+ where+ desc = "Expand or collapse text representation of date range.\n\+ \\n\+ \period collapse 2018-01-01,2018-12-31\n\+ \=> 2018\n\n\+ \period collapse 2018-01-01,2118-12-31\n\+ \=> 2018,2118\n\n\+ \period expand 2018-01\n\+ \=> 2018-01-01,2018-01-31\n\n\+ \period expand 2018-01-07,14\n\+ \=> 2018-01-07,2018-01-14\+ \" data Command- = Collapse PeriodFmt T.Text- | Expand {- expandFmt :: PeriodFmt,- expandInput :: T.Text,- expandList :: Bool+ = Collapse {+ colFmt :: PeriodFmt,+ colInput :: T.Text+ } | Expand {+ expFmt :: PeriodFmt,+ expInput :: T.Text,+ expList :: Bool } periodArg :: Parser T.Text@@ -34,7 +49,6 @@ short 'd' <> long "date-sep" <> value "," <> help "Start and end separator, by default ',' as in 'yyyy-mm-dd,yyyy-mm-dd'") - mkCommand :: String -> String -> Parser Command -> Mod CommandFields Command mkCommand cmd desc parser = command cmd $ info (helper <*> parser) (progDesc desc)@@ -48,9 +62,9 @@ ] runCommand :: Command -> IO ()-runCommand (Collapse fmt per) = T.putStrLn $ collapsePeriod fmt $ parsePeriod per-runCommand (Expand fmt expandInput expandList) = if- | expandList -> T.putStr . T.unlines . map (collapsePeriod fmt . (\x -> (x, x))) $ uncurry enumFromTo p- | otherwise -> T.putStrLn $ formatPeriod fmt p+runCommand Collapse{..} = T.putStrLn $ collapsePeriod colFmt $ parsePeriod colInput+runCommand Expand{..} = if+ | expList -> T.putStr . T.unlines . map (collapsePeriod expFmt . (\x -> (x, x))) $ uncurry enumFromTo p+ | otherwise -> T.putStrLn $ formatPeriod expFmt p where- p = parsePeriod expandInput+ p = parsePeriod expInput
period.cabal view
@@ -1,11 +1,11 @@ name: period-version: 0.1.0.6+version: 0.1.0.7 synopsis: Parse and format date periods, collapse and expand their text representations.--- description:+description: Library and executable to parse and format date periods, collapse and expand, e.g. 2018 → 2018-01-01,2018-12-31 and backwards. homepage: https://github.com/w3rs/period license: BSD3 license-file: LICENSE-author: Alexey Karakulov+author: Oleksii Karakulov maintainer: ankarakulov@gmail.com -- copyright: category: Text@@ -47,7 +47,8 @@ period, base, text,- optparse-applicative+ optparse-applicative,+ ansi-wl-pprint GHC-options: -Wall -O2 source-repository head