Skip to content

Commit 4e5cfa7

Browse files
committed
Conform stack build documentation to be more like other commands
1 parent c77b0af commit 4e5cfa7

File tree

1 file changed

+53
-56
lines changed

1 file changed

+53
-56
lines changed

doc/build_command.md

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,48 @@
33
# The `stack build` command and its synonyms
44

55
~~~text
6-
stack build [TARGET] [--dry-run] [--pedantic] [--fast]
7-
[--ghc-options OPTIONS] [--flag PACKAGE:[-]FLAG]
8-
[--dependencies-only | --only-snapshot |
9-
--only-dependencies | --only-locals]
10-
[--file-watch | --file-watch-poll] [--watch-all]
11-
[--exec COMMAND [ARGUMENT(S)]] [--only-configure]
12-
[--trace] [--profile] [--no-strip]
6+
stack build [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS]
7+
[--flag PACKAGE:[-]FLAG] [--dependencies-only | --only-snapshot |
8+
--only-dependencies | --only-locals] [--file-watch |
9+
--file-watch-poll] [--watch-all] [--exec COMMAND [ARGUMENT(S)]]
10+
[--only-configure] [--trace] [--profile] [--no-strip]
1311
[--[no-]library-profiling] [--[no-]executable-profiling]
1412
[--[no-]library-stripping] [--[no-]executable-stripping]
1513
[--[no-]haddock] [--haddock-arguments HADDOCK_ARGS]
16-
[--[no-]open] [--[no-]haddock-deps]
17-
[--[no-]haddock-internal]
14+
[--[no-]open] [--[no-]haddock-deps] [--[no-]haddock-internal]
1815
[--[no-]haddock-hyperlink-source] [--[no-]copy-bins]
19-
[--[no-]copy-compiler-tool] [--[no-]prefetch]
20-
[--[no-]keep-going] [--[no-]keep-tmp-files]
21-
[--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests]
22-
[--ta|--test-arguments TEST_ARGS] [--coverage]
16+
[--[no-]copy-compiler-tool] [--[no-]prefetch] [--[no-]keep-going]
17+
[--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test]
18+
[--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] [--coverage]
2319
[--no-run-tests] [--test-suite-timeout ARG]
2420
[--[no-]tests-allow-stdin] [--[no-]bench]
25-
[--ba|--benchmark-arguments BENCH_ARGS]
26-
[--no-run-benchmarks] [--[no-]reconfigure]
27-
[--cabal-verbosity VERBOSITY | --[no-]cabal-verbose]
28-
[--[no-]split-objs] [--skip ARG]
21+
[--ba|--benchmark-arguments BENCH_ARGS] [--no-run-benchmarks]
22+
[--[no-]reconfigure] [--cabal-verbosity VERBOSITY |
23+
--[no-]cabal-verbose] [--[no-]split-objs] [--skip ARG]
2924
[--[no-]interleaved-output] [--ddump-dir ARG]
3025
~~~
3126

32-
## Overview
33-
34-
Stack's primary command is `build`. This page describes its interface. The goal
35-
of the interface is to do the right thing for simple input, and allow
36-
flexibility for more complicated goals.
27+
`stack build` and its synonyms (`stack test`, `stack bench`, `stack haddock` and
28+
`stack install`) are Stack's primany command. The command provides a simple
29+
interface for simple tasks and flexibility for more complicated goals.
3730

3831
See the introductory part of Stack's
3932
[user's guide](GUIDE.md#the-stack-build-command) for an introduction to the
4033
command.
4134

4235
## Synonyms
4336

44-
The synonym commands for `build` are:
37+
The synonym commands for `stack build` are:
4538

46-
|Synonym command|Equivalent `build` command flag|
47-
|---------------|-------------------------------|
48-
|`stack test` |`stack build --test` |
49-
|`stack bench` |`stack build --bench` |
50-
|`stack haddock`|`stack build --haddock` |
51-
|`stack install`|`stack build --copy-bins` |
39+
|Synonym command|Equivalent `stack build` command flag|
40+
|---------------|-------------------------------------|
41+
|`stack test` |`stack build --test` |
42+
|`stack bench` |`stack build --bench` |
43+
|`stack haddock`|`stack build --haddock` |
44+
|`stack install`|`stack build --copy-bins` |
5245

5346
The advantage of the synonym commands is that they are convenient and short. The
54-
advantage of the flags is that they compose. For example,
55-
`stack build --test --copy-bins` will build libraries, executables, and test
56-
suites, run the test suites, and then copy the executables to your local bin
57-
path (more on this below).
47+
advantage of the flags is that they compose. See the examples below.
5848

5949
## Components
6050

@@ -370,26 +360,33 @@ specification and allow the executable to receive input on that channel. If you
370360
pass `--no-tests-allow-stdin` and the executable seeks input on the standard
371361
input channel, an exception will be thown.
372362

373-
## Composition
374-
375-
To come back to the composable approach described above, consider this example
376-
(which uses the `wai` [repository](https://github.com/yesodweb/wai/)). The
377-
command:
378-
379-
~~~text
380-
stack build --file-watch --test --copy-bins --haddock wai-extra :warp warp:doctest --exec 'echo Yay, it worked!'
381-
~~~
382-
383-
will start Stack up in file watch mode, waiting for files in your project to
384-
change. When first starting, and each time a file changes, it will do all of the
385-
following.
386-
387-
* Build the wai-extra package and its test suites
388-
* Build the `warp` executable
389-
* Build the warp package's doctest component (which, as you may guess, is a
390-
test site)
391-
* Run all of the wai-extra package's test suite components and the doctest test
392-
suite component
393-
* If all of that succeeds:
394-
* Copy generated executables to the local bin path
395-
* Run the command `echo Yay, it worked!`
363+
## Examples
364+
365+
* `stack build --test --copy-bins` or, equivalently, `stack test --copy-bins`
366+
or `stack install --test`, will build libraries, executables, and test
367+
suites, run the test suites, and then copy the executables to Stack's local
368+
binary directory (see `stack path --local-bin`). This is an example of the
369+
flags composing.
370+
371+
* The following example uses the
372+
`wai` [repository](https://github.com/yesodweb/wai/)). The `wai` project
373+
comprises a number of packages, including `wai-extra` and `warp`. The
374+
command:
375+
376+
~~~text
377+
stack build --file-watch --test --copy-bins --haddock wai-extra :warp warp:doctest --exec 'echo Yay, it worked!'
378+
~~~
379+
380+
will start Stack up in file watch mode, waiting for files in your project to
381+
change. When first starting, and each time a file changes, it will do all of
382+
the following.
383+
384+
* Build the `wai-extra` package and its test suites
385+
* Build the `warp` executable
386+
* Build the `warp` package's `doctest` component (which is a test site)
387+
* Run all of the `wai-extra` package's test suite components and the
388+
`doctest` test suite component
389+
* If all of that succeeds:
390+
* Copy generated executables to Stack's local binary directory (see
391+
`stack path --local-bin`)
392+
* Run the command `echo Yay, it worked!`

0 commit comments

Comments
 (0)