module Main where

import Byg.Types (Dependency)
import qualified Byg.DependencyRunner as DR
import qualified Byg.DependencyFormatter as DF
import Byg.DependencyGenerator (evalDepGenM)

import SiteGenerator (generateSite)

import System.Environment (getArgs)
import qualified Data.Text.IO as T

dependencies :: [Dependency]
dependencies = evalDepGenM generateSite

main :: IO ()
main = do
  args <- getArgs
  case args of
    [] -> do
      ((), filesWritten) <- DR.runDepRunMIO $ DR.runDeps dependencies
      putStrLn ("Files which could have been written: " ++ show filesWritten)
    ["tree"] ->
      T.putStr $ DF.formatDependencyTrees dependencies
    _ ->
      error "unexpected arguments"
