diff --git a/byg/src/DependencyRunner.hs b/byg/src/DependencyRunner.hs index f014bcf..d46cade 100644 --- a/byg/src/DependencyRunner.hs +++ b/byg/src/DependencyRunner.hs @@ -1,7 +1,7 @@ module DependencyRunner ( DepRunM , runDeps - , runDepRunM + , runDepRunMIO ) where import Types (Value(..), Valuable(..)) @@ -19,8 +19,8 @@ newtype DepRunM a = DepRunM { unDepRunM :: StateT (Map Int Value) IO a } runDeps :: [Dependency] -> DepRunM () runDeps = mapM_ runDep -runDepRunM :: DepRunM a -> IO a -runDepRunM m = evalStateT (unDepRunM m) M.empty +runDepRunMIO :: DepRunM a -> IO a +runDepRunMIO m = evalStateT (unDepRunM m) M.empty runDep :: Dependency -> DepRunM () runDep (Dependency a action b) = do diff --git a/byg/src/Main.hs b/byg/src/Main.hs index 40ab697..6002d14 100644 --- a/byg/src/Main.hs +++ b/byg/src/Main.hs @@ -4,7 +4,9 @@ module Main where import Types.Dependency (Dependency, formatDependencyTrees) import DependencyGenerator (evalDepGenM) import SiteGenerator (generateSite) +import DependencyRunner (runDeps, runDepRunMIO) +import System.Environment (getArgs) import qualified Data.Text.IO as T import Language.Haskell.TH.Syntax (lift) @@ -12,4 +14,12 @@ dependencies :: [Dependency] dependencies = $(lift (evalDepGenM generateSite)) main :: IO () -main = T.putStr $ formatDependencyTrees dependencies +main = do + args <- getArgs + case args of + ["run"] -> + runDepRunMIO $ runDeps dependencies + ["tree"] -> + T.putStr $ formatDependencyTrees dependencies + _ -> + error "unexpected arguments"