Skip to content

Add a doc section on cabal list-bin. #7964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 85 additions & 2 deletions doc/cabal-commands.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
cabal-install Commands
======================

We now give an in-depth description of all the commands, first describing the
arguments and flags that are common to some or all of them.
``cabal help`` groups commands into global, package, new-style project and
legacy sections. We talk in detail about some of the new-style project commands,
``help`` and ``list-bin`` but there are other commands.

::

$ cabal help
Command line interface to the Haskell Cabal infrastructure.

See http://www.haskell.org/cabal/ for more information.

Usage: cabal [GLOBAL FLAGS] [COMMAND [FLAGS]]

Commands:
[global]
help Help about commands.

[package]
list-bin list path to a single executable.

[new-style projects (forwards-compatible aliases)]
v2-build Compile targets within the project.
v2-configure Add extra project configuration
v2-repl Open an interactive session for the given component.
v2-run Run an executable.
v2-test Run test-suites
v2-bench Run benchmarks
v2-freeze Freeze dependencies.
v2-haddock Build Haddock documentation
v2-exec Give a command access to the store.
v2-update Updates list of known packages.
v2-install Install packages.
v2-clean Clean the package store and remove temporary files.
v2-sdist Generate a source distribution file (.tar.gz).

[legacy command aliases]
No legacy commands are described.

Common Arguments and Flags
--------------------------

Arguments and flags common to some or all commands are:


.. option:: --default-user-config=file
Expand Down Expand Up @@ -142,6 +182,49 @@ arguments and flags that are common to some or all of them.
Already generated `build-info.json` files will be removed since they would be stale otherwise.


cabal list-bin
--------------

``cabal list-bin`` will either (a) display the path for a single executable or (b)
complain that the target doesn't resolve to a single binary. In the latter case,
it will name the binary products contained in the package. These products can
be used to narrow the search and get an actual path to a particular executable.

Example showing a failure to resolve to a single executable.

::

$ cabal list-bin cabal-install
cabal: The list-bin command is for finding a single binary at once. The
target 'cabal-install' refers to the package cabal-install-#.#.#.# which
includes the executable 'cabal', the test suite 'unit-tests', the test suite
'memory-usage-tests', the test suite 'long-tests' and the test suite
'integration-tests2'.

For a scope that results in only one item we'll get a path.

::

$ cabal list-bin cabal-install:exes
/.../dist-newstyle/build/.../cabal/cabal

$ cabal list-bin cabal-install:cabal
/.../dist-newstyle/build/.../cabal/cabal

We can also scope to test suite targets as they produce binaries.

::

$ cabal list-bin cabal-install:tests
cabal: The list-bin command is for finding a single binary at once. The
target 'cabal-install:tests' refers to the test suites in the package
cabal-install-#.#.#.# which includes the test suite 'unit-tests', the test
suite 'memory-usage-tests', the test suite 'long-tests' and the test suite
'integration-tests2'.

$ cabal list-bin cabal-install:unit-tests
/.../dist-newstyle/.../unit-tests/unit-tests

cabal v2-configure
-------------------

Expand Down