haskell/cabal — pull request #1989 by fujimura (2014-07-10 15:34:01+00:00)
Title: Ask source directory in cabal init

From #1967.

- `hs-source-dirs` will be asked at last of interactive prompt, and the answer will be added to `.cabal`
- Default is `none`, which doesn't add `hs-source-dirs`
- Won't ask source directory if `src` exists.

@byorgey Thanks for pointing out where to start! Could you review this?

Example:

```
$ cabal init
...
Source directory:
* 1) (none)
2) src
3) Other (specify)
Your choice? [default: (none)] 2

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating sample.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.
```

This will generate `src` directory:
```
$ tree .
.
├── Setup.hs
├── sample.cabal
└── src
```

And add `hs-source-dirs`:

```
$ cat sample.cabal
-- Initial sample.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/

name: sample
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
author: Fujimura Daisuke
maintainer: me@fujimuradaisuke.com
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10

library
-- exposed-modules:
-- other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8
hs-source-dirs: src
default-language: Haskell2010
```