1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3 module Main
(main
) where
5 import Control
.Exception
(SomeException
(..), catch, displayException
)
6 import GHC
.Generics
(Generic
)
7 import System
.Environment
(getArgs)
8 import System
.Exit
(exitFailure)
10 import qualified Zinza
as Z
12 withIO
:: (Bool -> FilePath -> FilePath -> IO a
) -> IO a
17 | Just dev
<- parseBool dev
'
18 -> k dev src tgt `
catch`
\(SomeException e
) -> do
19 putStrLn $ "Exception: " ++ displayException e
22 putStrLn "Usage cabal run ... source.temeplate.ext target.ext"
25 parseBool
"True" = Just
True
26 parseBool
"False" = Just
False
31 main
= withIO
$ \dev src tgt
-> do
32 render
<- Z
.parseAndCompileTemplateIO src
33 contents
<- render
$ Z dev
()
34 writeFile tgt contents
36 -------------------------------------------------------------------------------
38 -------------------------------------------------------------------------------
46 instance Z
.Zinza Z
where
47 toType
= Z
.genericToTypeSFP
48 toValue
= Z
.genericToValueSFP
49 fromValue
= Z
.genericFromValueSFP