haskell / haskell/cabal

`cabal init` bootstraps a test suite *only* by default when `interactive` is set to False in the global configuration

Open
#11,377 1 comment 0 reactions 0 assignees View on GitHub
cabal-install: cmd/init re: user experience type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

## Actual behaviour

Here is the output from a simple `cabal init` in my terminal:

```
hecate@ifrit ~/gperf-example ❯ cabal init
Package name? [default: gperf-example]
Package version? [default: 0.1.0.0]
Author name?
Maintainer email?
Project homepage URL? [optional]
Project synopsis? [optional]
Project category:
1) Codec
2) Concurrency
3) Control
4) Data
5) Database
6) Development
7) Distribution
8) Game
9) Graphics
10) Language
11) Math
12) Network
13) Sound
14) System
15) Testing
16) Text
17) Web
18) Other (specify)
Your choice? [default: (none)] 18
Please specify? [optional]
What is the main module of the test suite?:
* 1) Main.hs
2) Main.lhs
3) Other (specify)
Your choice? [default: Main.hs]
Add informative comments to each field in the cabal file. (y/n)? [default: y] n
[Info] Using cabal specification: 3.6
[Info] Creating fresh file LICENSE...
[Info] Creating fresh file CHANGELOG.md...
[Info] Creating fresh directory ./test...
[Info] Creating fresh file test/Main.hs...
[Info] Creating fresh file gperf-example.cabal...
[Warn] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.
```

This only gives me a test suite with the cabal file. I tried on another machine which gave me the option for the build target, and it would appear that setting `interactive` to `False` in the global configuration sets `Test suite` by default, whereas "Executable" is offered by default in the interactive menu.

My configuration block for `cmd/init` was as follows:

```cabal
init
-- interactive: False
cabal-version: 3.6
license: MIT
tests: True
test-dir: test
language: GHC2021
application-dir: app
source-dir: src
```

**None of these options** advertise that their combination will only produce a test suite and not an executable or a library.

## Expected behaviour

**As an end-user I expect the interactive and non-interactive menus to be consistent**. Moreover, generating a test suite by default is useless and amounts for too niche of a use case for it to be set as the non-interactive default.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.