module Main where
import Lib
+import System.Environment
+import System.Exit
+import System.Directory
+import Prelude hiding (init)
+import Data.List (intercalate)
+import Text.JSON
+import Data.Text hiding (intercalate, unlines, init)
+
+data Project = Project {
+ name :: Text,
+ description :: Text
+ } deriving (Show)
main :: IO ()
-main = someFunc
+main = getArgs >>= parse
+
+init :: IO ()
+init = do
+ dirExists <- doesDirectoryExist "entries"
+ if dirExists
+ then putStrLn "Project already initialised"
+ else do createDirectory "entries"
+ putStrLn "Enter a name for your project:"
+ projectName <- getLine
+ putStrLn "Enter short description for your project:"
+ projectDescription <- getLine
+ writeFile "xyz.json" . encode . toJSObject $ [("name", projectName), ("description", projectDescription), ("theme", "xyz")]
+ putStrLn "Initialised empty project"
+
+
+ununlines :: [String] -> String
+ununlines = intercalate "\n\n"
+
+usage :: IO ()
+usage = putStr . ununlines $ [
+ "usage: xyz <command>",
+ "Commands:", unlines [
+ "\tinit\t\tInitialise a new site",
+ "\tbuild\t\tBuild the site"
+ ]
+ ]
+
+parse ["init"] = init >> exit
+parse ["build"] = putStrLn "would do a build" >> exit
+parse [_] = usage >> exit
+parse [] = usage >> exit
+
+exit = exitWith ExitSuccess