module Hscaffold.EDSL where
import Control.Monad.Writer
import Data.Text (Text)
import System.Directory
import Hscaffold.Types
directory :: MonadWriter (ScaffoldAction e) m
=> FilePath
-> WriterT (ScaffoldAction e) m b
-> m b
directory fp nested = do
(x, nested') <- runWriterT nested
tell [ Directory fp nested' ]
return x
directoryWith :: MonadWriter (ScaffoldAction e) m
=> Permissions
-> FilePath
-> WriterT (ScaffoldAction e) m b
-> m b
directoryWith perms fp nested = do
x <- directory fp nested
tell [ SetPermissions perms fp ]
return x
file :: MonadWriter (ScaffoldAction e) m => FilePath -> Text -> m ()
file fp txt = tell [ File fp txt ]
fileWith :: MonadWriter (ScaffoldAction e) m
=> Permissions
-> FilePath
-> Text
-> m ()
fileWith perms fp txt = do
file fp txt
tell [ SetPermissions perms fp ]
permissions :: MonadWriter (ScaffoldAction e) m
=> FilePath
-> Permissions
-> m ()
permissions fp perms = tell [ SetPermissions perms fp ]
link :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m ()
link fp1 fp2 = tell [ Link fp1 fp2 ]
touch :: MonadWriter (ScaffoldAction e) m => FilePath -> m ()
touch fp = file fp ""
touchWith :: MonadWriter (ScaffoldAction e) m => Permissions -> FilePath -> m ()
touchWith perms fp = fileWith perms fp ""
copy :: MonadWriter (ScaffoldAction e) m => FilePath -> FilePath -> m ()
copy fp1 fp2 = tell [ Copy fp1 fp2 ]
copyWith :: MonadWriter (ScaffoldAction e) m
=> Permissions
-> FilePath
-> FilePath
-> m ()
copyWith perms fp1 fp2 = do
copy fp1 fp2
permissions fp2 perms