1{-# LANGUAGE OverloadedStrings #-}
8import Prelude hiding (init)
9import Control.Monad.Trans (liftIO)
10import qualified Data.Map as Map
11import qualified System.Directory as Dir
13import qualified Deps.Registry as Registry
14import qualified Deps.Solver as Solver
15import qualified Elm.Constraint as Con
16import qualified Elm.Outline as Outline
17import qualified Elm.Package as Pkg
18import qualified Elm.Version as V
20import qualified Reporting
21import qualified Reporting.Doc as D
22import qualified Reporting.Exit as Exit
30run :: () -> () -> IO ()
32 Reporting.attempt Exit.initToReport $
33 do exists <- Dir.doesFileExist "elm.json"
35 then return (Left Exit.InitAlreadyExists)
37 do approved <- Reporting.ask question
41 do putStrLn "Okay, I did not make any changes!"
50 ,"Elm","projects","always","start","with","an",D.green "elm.json","file."
51 ,"I","can","create","them!"
54 "Now you may be wondering, what will be in this file? How do I add Elm files to\
55 \ my project? How do I see it in the browser? How will my code grow? Do I need\
56 \ more directories? What about tests? Etc."
58 ["Check","out",D.cyan (D.fromChars (D.makeLink "init"))
59 ,"for","all","the","answers!"
61 , "Knowing all that, would you like me to create an elm.json file now? [Y/n]: "
69init :: IO (Either Exit.Init ())
71 do cache <- Stuff.getPackageCache
72 manager <- Http.getManager
73 eregistry <- Registry.latest manager cache
76 return (Left (Exit.InitRegistryProblem rp))
79 do result <- Solver.online cache manager registry defaults
82 return (Left (Exit.InitNoSolution (Map.keys defaults)))
86 solution = Map.map (\(Solver.Details vsn _) -> vsn) details
87 directs = Map.intersection solution defaults
88 indirects = Map.difference solution defaults
90 do Dir.createDirectoryIfMissing True "src"
91 Outline.write "." $ Outline.App $
92 Outline.AppOutline V.compiler ["src"] directs indirects Map.empty Map.empty
93 putStrLn "Okay, I created it. Now read that link!"
97defaults :: Map.Map Pkg.Name Con.Constraint
100 [ (Pkg.core, Con.anything)
101 , (Pkg.browser, Con.anything)
102 , (Pkg.html, Con.anything)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list