module Shaker.Action.Standard
where
import Shaker.Type
import qualified Data.Map as M
import Control.Monad.Trans
import Control.Monad.Reader
import System.Directory
import Control.Concurrent
runHelp :: Plugin
runHelp = do
commands <- asks commandMap
lift $ do
putStrLn "Following actions are available : "
print $ M.keys commands
putStrLn "use ~[actionName] for continuous launch"
runExit :: Plugin
runExit = do
lift $ putStrLn "Exiting"
quit_token <- asks (quitToken . threadData)
lift $ putMVar quit_token 42
runStartAction :: Plugin
runStartAction = lift $
putStrLn "---------- Begin action -------------------------"
runEmpty :: Plugin
runEmpty = return ()
runEndAction :: Plugin
runEndAction = lift $
putStrLn "---------- End action ---------------------------"
runClean :: Plugin
runClean = do
toClean <- asks $ map cfCompileTarget . compileInputs
lift$ mapM_ action toClean
where action toClean = do
ex <- doesDirectoryExist toClean
if ex then removeDirectoryRecursive toClean
else putStrLn ""
runInvalidAction :: Plugin
runInvalidAction = lift $ putStrLn "Invalid action, use help to display available actions"