packages feed

ascii-holidays-0.1.0.0: Main.hs

{-# LANGUAGE
     LambdaCase
   #-}

import BashTree
import PerlTree

import System.Environment (getArgs)

main :: IO ()
main = do
   getArgs >>= \case
      [] -> do
         putStrLn "No animation name provided"
         putStrLn animationChoiceList
      [animationName] -> case [ action | (nm, _, action) <- animations, nm == animationName ] of
         [] -> do
            putStrLn "No animation with that name!"
            putStrLn animationChoiceList
         [ action ] -> action
         _ -> error "More than one animation with the same name"
      _ -> do
         putStrLn "Please only provide the name of one animation"
         putStrLn animationChoiceList

animations :: [(String, String, IO ())]
animations = [
     ("xmas-0", "Christmas tree, based on https://github.com/sergiolepore/ChristBASHTree", drawBashTree)
   , ("xmas-1", "Christmas tree, based on https://github.com/rcaputo/acme-poe-tree", drawPerlTree)
   ]

animationChoiceList :: String
animationChoiceList =
   "\nChoices:\n"++
   unlines [ "  "++name++"  -  "++description | (name, description, _) <- animations ]