Skip to content

Commit c4e1268

Browse files
authored
Merge pull request #9217 from BinderDavid/remove-duplicate-documentation
Deduplicate documentation of cabal commands
2 parents ed8acd9 + e902b1c commit c4e1268

File tree

2 files changed

+113
-213
lines changed

2 files changed

+113
-213
lines changed

doc/cabal-commands.rst

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,31 +398,46 @@ Check ``cabal fetch --help`` for a complete list of options.
398398
cabal get
399399
^^^^^^^^^
400400

401-
``cabal get [PACKAGES]`` (synonym: ``cabal unpack``) downloads and unpacks
401+
``cabal get [FLAGS] [PACKAGES]`` (synonym: ``cabal unpack``) downloads and unpacks
402402
the source code of ``PACKAGES`` locally. By default the content of the
403403
packages is unpacked in the current working directory, in named subfolders
404404
(e.g. ``./filepath-1.2.0.8/``), use ``--destdir=PATH`` to specify another
405405
folder. By default the latest version of the package is downloaded, you can
406406
ask for a spefic one by adding version numbers
407407
(``cabal get random-1.0.0.1``).
408408

409+
The ``cabal get`` command supports the following options:
410+
409411
.. option:: -s[[head|this|...]], --source-repository[=[head|this|...]]
410412

411-
Clone the package's source repository (Darcs, Git, etc.) instead
412-
of downloading the tarball. Only works if the package specifies
413-
a ``source-repository``.
413+
Clone the package's source repository (Darcs, Git, etc.)
414+
instead of downloading the tarball. Only works if the
415+
package specifies a ``source-repository``.
414416

415417
.. option:: --index-state=STATE
416418

417419
Pin your request to a specific Hackage index state. Available
418420
``STATE`` formats: Unix timestamps (e.g. ``@1474732068``),
419421
ISO8601 UTC timestamps (e.g. ``2016-09-24T17:47:48Z``), or ``HEAD``
420422
(default).
423+
This determines which package versions are available as well as which
424+
``.cabal`` file revision is selected (unless ``--pristine`` is used).
421425

422426
.. option:: --pristine
423427

424428
Unpacks the pristine tarball, i.e. disregarding any Hackage revision.
425429

430+
.. option:: -d, --destdir=PATH
431+
432+
Where to place the package source, defaults to (a subdirectory of)
433+
the current directory.
434+
435+
.. option:: --only-package-description, --package-description-only
436+
437+
Unpack the original pristine tarball, rather than updating the
438+
``.cabal`` file with the latest revision from the package archive.
439+
440+
426441
.. _command-group-config:
427442

428443
Project configuration
@@ -478,6 +493,12 @@ flag.
478493
cabal freeze
479494
^^^^^^^^^^^^
480495

496+
If a package is built in several different environments, such as a
497+
development environment, a staging environment and a production
498+
environment, it may be necessary or desirable to ensure that the same
499+
dependency versions are selected in each environment. This can be done
500+
with the ``freeze`` command:
501+
481502
``cabal freeze`` writes out a **freeze file** which records all of
482503
the versions and flags that are picked by the solver under the
483504
current index and flags. Default name of this file is
@@ -511,15 +532,88 @@ cabal gen-bounds
511532
``cabal gen-bounds [FLAGS]`` generates bounds for all dependencies that do not
512533
currently have them. Generated bounds are printed to stdout. You can then
513534
paste them into your .cabal file.
535+
The generated bounds conform to the `Package Versioning Policy`_, which is
536+
a recommended versioning system for publicly released Cabal packages.
537+
538+
.. code-block:: console
539+
540+
$ cabal gen-bounds
541+
542+
For example, given the following dependencies without bounds specified in
543+
:pkg-field:`build-depends`:
544+
545+
::
546+
547+
build-depends:
548+
base,
549+
mtl,
550+
transformers,
551+
552+
``gen-bounds`` might suggest changing them to the following:
553+
554+
::
555+
556+
build-depends:
557+
base >= 4.15.0 && < 4.16,
558+
mtl >= 2.2.2 && < 2.3,
559+
transformers >= 0.5.6 && < 0.6,
514560

515-
See `the section on generating dependency version bounds <cabal-package.html#generating-dependency-version-bounds>`__ for more details and examples.
516561

517562
cabal outdated
518563
^^^^^^^^^^^^^^
519564

520565
``cabal outdated [FLAGS]`` checks for outdated dependencies in the package
521566
description file or freeze file.
522567

568+
Manually updating dependency version bounds in a ``.cabal`` file or a
569+
freeze file can be tedious, especially when there's a lot of
570+
dependencies. The ``cabal outdated`` command is designed to help with
571+
that. It will print a list of packages for which there is a new
572+
version on Hackage that is outside the version bound specified in the
573+
``build-depends`` field. The ``outdated`` command can also be
574+
configured to act on the freeze file and
575+
ignore major (or all) version bumps on Hackage for a subset of
576+
dependencies.
577+
578+
Examples:
579+
580+
.. code-block:: console
581+
582+
$ cd /some/package
583+
$ cabal outdated
584+
Outdated dependencies:
585+
haskell-src-exts <1.17 (latest: 1.19.1)
586+
language-javascript <0.6 (latest: 0.6.0.9)
587+
unix ==2.7.2.0 (latest: 2.7.2.1)
588+
589+
$ cabal outdated --simple-output
590+
haskell-src-exts
591+
language-javascript
592+
unix
593+
594+
$ cabal outdated --ignore=haskell-src-exts
595+
Outdated dependencies:
596+
language-javascript <0.6 (latest: 0.6.0.9)
597+
unix ==2.7.2.0 (latest: 2.7.2.1)
598+
599+
$ cabal outdated --ignore=haskell-src-exts,language-javascript,unix
600+
All dependencies are up to date.
601+
602+
$ cabal outdated --ignore=haskell-src-exts,language-javascript,unix -q
603+
$ echo $?
604+
0
605+
606+
$ cd /some/other/package
607+
$ cabal outdated --freeze-file
608+
Outdated dependencies:
609+
HTTP ==4000.3.3 (latest: 4000.3.4)
610+
HUnit ==1.3.1.1 (latest: 1.5.0.0)
611+
612+
$ cabal outdated --freeze-file --ignore=HTTP --minor=HUnit
613+
Outdated dependencies:
614+
HUnit ==1.3.1.1 (latest: 1.3.1.2)
615+
616+
523617
``cabal outdated`` supports the following flags:
524618

525619
.. option:: --freeze-file
@@ -575,8 +669,6 @@ description file or freeze file.
575669
be used without arguments, in that case major version bumps are ignored for
576670
all packages.
577671

578-
See `the section on listing outdated dependency version bounds <cabal-package.html#listing-outdated-dependency-version-bounds>`__ for more details and examples.
579-
580672
.. _command-group-build:
581673

582674
Project building and installing
@@ -1157,3 +1249,5 @@ cabal report
11571249
.. option:: -p PASSWORD or -pPASSWORD, --password=PASSWORD
11581250

11591251
Your Hackage password.
1252+
1253+
.. include:: references.inc

0 commit comments

Comments
 (0)