-continueIfValidProject nextfn = do
- jsonExists <- doesFileExist "xyz.json"
- if jsonExists
- then nextfn
- else putStrLn "This does not appear to be a valid project directory"
+continueIfValidProject next = doesFileExist "xyz.json" >>= bool (putStrLn "This does not appear to be a valid project directory") next
+
+initGlobalIfNeeded :: IO () -> IO ()
+initGlobalIfNeeded next = getGlobalProjectConfig >>= doesFileExist >>= bool globalInit (return ()) >> next
+
+globalInit :: IO ()
+globalInit = do
+ home <- getHomeDirectory
+ putStrLn "\nWelcome to xyz! Looks like this is your first time here. Let's configure a few things...\n"
+ editor <- editorPrompt
+ writeFile (home ++ "/.xyz/xyz.json") (pack . encode . toJSObject $ [("editor", editor)])
+ putStrLn "\nThanks! Now let's continue with initialising your project...\n"