1{-# LANGUAGE OverloadedStrings #-}
8import Prelude hiding (init)
9import qualified Data.Map as Map
10import qualified System.Directory as Dir
12import qualified Deps.Solver as Solver
13import qualified Elm.Constraint as Con
14import qualified Elm.Outline as Outline
15import qualified Elm.Package as Pkg
16import qualified Elm.Version as V
17import qualified Reporting
18import qualified Reporting.Doc as D
19import qualified Reporting.Exit as Exit
26run :: () -> () -> IO ()
28 Reporting.attempt Exit.initToReport $
29 do exists <- Dir.doesFileExist "elm.json"
31 then return (Left Exit.InitAlreadyExists)
33 do approved <- Reporting.ask question
37 do putStrLn "Okay, I did not make any changes!"
46 ,"Elm","projects","always","start","with","an",D.green "elm.json","file."
47 ,"I","can","create","them!"
50 "Now you may be wondering, what will be in this file? How do I add Elm files to\
51 \ my project? How do I see it in the browser? How will my code grow? Do I need\
52 \ more directories? What about tests? Etc."
54 ["Check","out",D.cyan (D.fromChars (D.makeLink "init"))
55 ,"for","all","the","answers!"
57 , "Knowing all that, would you like me to create an elm.json file now? [Y/n]: "
65init :: IO (Either Exit.Init ())
67 do eitherEnv <- Solver.initEnv
70 return (Left (Exit.InitRegistryProblem problem))
72 Right (Solver.Env cache _ connection registry) ->
73 do result <- Solver.verify cache connection registry defaults
76 return (Left (Exit.InitSolverProblem exit))
79 return (Left (Exit.InitNoSolution (Map.keys defaults)))
81 Solver.NoOfflineSolution ->
82 return (Left (Exit.InitNoOfflineSolution (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