Include the GHC "Project Unit Id" in the cabal store path
[cabal.git] / cabal-install / src / Distribution / Client / Init.hs
blob1a8be086a3ff09f859f92bb10414c34ae6a23213
1 -----------------------------------------------------------------------------
3 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Distribution.Client.Init
7 -- Copyright : (c) Brent Yorgey 2009
8 -- License : BSD-like
9 --
10 -- Maintainer : cabal-devel@haskell.org
11 -- Stability : provisional
12 -- Portability : portable
14 -- Implementation of the 'cabal init' command, which creates an initial .cabal
15 -- file for a project.
16 module Distribution.Client.Init (initCmd) where
18 import Distribution.Client.IndexUtils
19 import Distribution.Client.Init.FileCreators
20 import qualified Distribution.Client.Init.Interactive.Command as Interactive
21 import qualified Distribution.Client.Init.NonInteractive.Command as NonInteractive
22 import qualified Distribution.Client.Init.Simple as Simple
23 import Distribution.Client.Init.Types
24 import Distribution.Client.Setup (RepoContext)
25 import Distribution.Simple.Compiler
26 import Distribution.Simple.Program (ProgramDb)
27 import Distribution.Simple.Setup
28 import Distribution.Verbosity
29 import System.IO (BufferMode (NoBuffering), hSetBuffering, stdout)
31 -- | This is the main driver for the init script.
32 initCmd
33 :: Verbosity
34 -> PackageDBStack
35 -> RepoContext
36 -> Compiler
37 -> ProgramDb
38 -> InitFlags
39 -> IO ()
40 initCmd v packageDBs repoCtxt comp progdb initFlags = do
41 installedPkgIndex <- getInstalledPackages v comp packageDBs progdb
42 sourcePkgDb <- getSourcePackages v repoCtxt
43 hSetBuffering stdout NoBuffering
44 settings <- createProject v installedPkgIndex sourcePkgDb initFlags
45 writeProject settings
46 where
47 -- When no flag is set, default to interactive.
49 -- When `--interactive` is set, if we also set `--simple`,
50 -- then we interactive generate a simple project with sensible defaults.
52 -- If `--simple` is not set, default to interactive. When the flag
53 -- is explicitly set to `--non-interactive`, then we choose non-interactive.
55 createProject
56 | fromFlagOrDefault False (simpleProject initFlags) =
57 Simple.createProject
58 | otherwise = case interactive initFlags of
59 Flag False -> NonInteractive.createProject comp
60 _ -> Interactive.createProject