module Rob.Actions.Add (main) where import Rob.Logger (err, success) import Rob.Config (get, addTemplate) import Rob.Project (hasPathQuestionnaire) import Rob.UserMessages (projectPathDoesNotExist, projectQuestionnaireMissing, projectAdded) import System.Exit (exitFailure, exitSuccess) import System.Directory (doesPathExist) main :: String -> FilePath -> IO() main :: String -> String -> IO () main String name String path = do Bool hasProjectPath <- String -> IO Bool doesPathExist String path if Bool hasProjectPath then do Bool hasQuestionnaire <- String -> IO Bool hasPathQuestionnaire String path if Bool hasQuestionnaire then do Config config <- IO Config get Config _ <- Config -> String -> String -> IO Config addTemplate Config config String name String path String -> IO () success (String -> IO ()) -> String -> IO () forall a b. (a -> b) -> a -> b $ String -> String projectAdded String name IO () forall a. IO a exitSuccess else do String -> IO () err (String -> IO ()) -> String -> IO () forall a b. (a -> b) -> a -> b $ String -> String projectQuestionnaireMissing String path IO () forall a. IO a exitFailure else do String -> IO () err (String -> IO ()) -> String -> IO () forall a b. (a -> b) -> a -> b $ String -> String projectPathDoesNotExist String path IO () forall a. IO a exitFailure