1{-# LANGUAGE OverloadedStrings #-}
8import Prelude hiding (init)
9import qualified Data.Map as Map
10import qualified Data.NonEmptyList as NE
11import qualified System.Directory as Dir
13import qualified Deps.Solver as Solver
14import qualified Elm.Constraint as Con
15import qualified Elm.Outline as Outline
16import qualified Elm.Package as Pkg
17import qualified Elm.Version as V
18import qualified Reporting
19import qualified Reporting.Doc as D
20import qualified Reporting.Exit as Exit
27run :: () -> () -> IO ()
29 Reporting.attempt Exit.initToReport $
30 do exists <- Dir.doesFileExist "elm.json"
32 then return (Left Exit.InitAlreadyExists)
34 do approved <- Reporting.ask question
38 do putStrLn "Okay, I did not make any changes!"
47 ,"Elm","projects","always","start","with","an",D.green "elm.json","file."
48 ,"I","can","create","them!"
51 "Now you may be wondering, what will be in this file? How do I add Elm files to\
52 \ my project? How do I see it in the browser? How will my code grow? Do I need\
53 \ more directories? What about tests? Etc."
55 ["Check","out",D.cyan (D.fromChars (D.makeLink "init"))
56 ,"for","all","the","answers!"
58 , "Knowing all that, would you like me to create an elm.json file now? [Y/n]: "
66init :: IO (Either Exit.Init ())
68 do eitherEnv <- Solver.initEnv
71 return (Left (Exit.InitRegistryProblem problem))
73 Right (Solver.Env cache _ connection registry) ->
74 do result <- Solver.verify cache connection registry defaults
77 return (Left (Exit.InitSolverProblem exit))
80 return (Left (Exit.InitNoSolution (Map.keys defaults)))
82 Solver.NoOfflineSolution ->
83 return (Left (Exit.InitNoOfflineSolution (Map.keys defaults)))
87 solution = Map.map (\(Solver.Details vsn _) -> vsn) details
88 directs = Map.intersection solution defaults
89 indirects = Map.difference solution defaults
91 do Dir.createDirectoryIfMissing True "src"
92 Outline.write "." $ Outline.App $
93 Outline.AppOutline V.compiler (NE.List "src" []) directs indirects Map.empty Map.empty
94 putStrLn "Okay, I created it. Now read that link!"
98defaults :: Map.Map Pkg.Name Con.Constraint
101 [ (Pkg.core, Con.anything)
102 , (Pkg.browser, Con.anything)
103 , (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