1 -----------------------------------------------------------------------------
3 -----------------------------------------------------------------------------
6 -- Module : Distribution.Client.Init
7 -- Copyright : (c) Brent Yorgey 2009
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.
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
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.
56 | fromFlagOrDefault
False (simpleProject initFlags
) =
58 |
otherwise = case interactive initFlags
of
59 Flag
False -> NonInteractive
.createProject comp
60 _
-> Interactive
.createProject