Skip to content

Commit 7447d1f

Browse files
committed
Update 'cabal path' documentation
1 parent e9fbbea commit 7447d1f

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

doc/cabal-commands.rst

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,58 @@ cabal preferences. It is very useful when you are e.g. first configuring
288288
cabal path
289289
^^^^^^^^^^
290290

291-
``cabal path`` prints the file system paths used by ``cabal`` for
292-
cache, store, installed binaries, and so on. When run without any
293-
options, it will show all paths, labeled with how they are namen in
294-
the configuration file:
291+
``cabal path`` allows to query for paths used by ``cabal``.
292+
For example, it allows to query for the directories of the cache, store,
293+
installed binaries, and so on. When queried, each path output is labelled by their respective flag name.
294+
295+
The command ``cabal path`` requires the ``output-format`` argument (e.g., ``json`` or ``key-value``)
296+
that specifies the format of the output:
297+
298+
::
299+
300+
$ cabal path --output-format=key-value
301+
cache-dir: /home/haskell/.cache/cabal/packages
302+
logs-dir: /home/haskell/.cache/cabal/logs
303+
store-dir: /home/haskell/.local/state/cabal/store
304+
config-file: /home/haskell/.config/cabal/config
305+
installdir: /home/haskell/.local/bin
306+
...
307+
308+
Or using the json output:
295309

296310
::
297-
$ cabal path
298-
cache-dir: /home/haskell/.cache/cabal/packages
299-
logs-dir: /home/haskell/.cache/cabal/logs
300-
store-dir: /home/haskell/.local/state/cabal/store
301-
config-file: /home/haskell/.config/cabal/config
302-
installdir: /home/haskell/.local/bin
303-
...
304311

305-
If ``cabal path`` is passed a single option naming a path, then that
312+
$ cabal path --output-format=json
313+
314+
.. code-block:: json
315+
316+
{
317+
"cabal-version": "3.11.0.0",
318+
"compiler": {
319+
"flavour": "ghc",
320+
"id": "ghc-9.6.4",
321+
"path": "/home/user/.ghcup/bin/ghc"
322+
},
323+
"cache-dir": "/home/user/.cabal/packages",
324+
"logs-dir": "/home/user/.cabal/logs",
325+
"store-dir": "/home/user/.cabal/store",
326+
"config-file": "/home/user/.cabal/config",
327+
"installdir": "/home/user/.cabal/bin"
328+
}
329+
330+
If ``cabal path --output-format=key-value`` is passed a single option naming a path, then that
306331
path will be printed *without* any label:
307332

308333
::
309334

310-
$ cabal path --installdir
335+
$ cabal path --output-format=key-value --installdir
311336
/home/haskell/.local/bin
312337

313-
This is a stable interface and is intended to be used for scripting.
314-
For example:
338+
While this interface is intended to be used for scripting, it is an experimental command.
339+
Scripting example:
315340

316341
::
317-
$ ls $(cabal path --installdir)
342+
$ ls $(cabal path --output-format=key-value --installdir)
318343
...
319344

320345
.. _command-group-database:
@@ -1381,8 +1406,8 @@ to Hackage.
13811406

13821407
.. option:: -t TOKEN or -tTOKEN, --token=TOKEN
13831408

1384-
Your Hackage authentication token. You can create and delete
1385-
authentication tokens on Hackage's `account management page
1409+
Your Hackage authentication token. You can create and delete
1410+
authentication tokens on Hackage's `account management page
13861411
<https://hackage.haskell.org/users/account-management>`__.
13871412

13881413
.. option:: -u USERNAME or -uUSERNAME, --username=USERNAME
@@ -1416,8 +1441,8 @@ cabal report
14161441

14171442
.. option:: -t TOKEN or -tTOKEN, --token=TOKEN
14181443

1419-
Your Hackage authentication token. You can create and delete
1420-
authentication tokens on Hackage's `account management page
1444+
Your Hackage authentication token. You can create and delete
1445+
authentication tokens on Hackage's `account management page
14211446
<https://hackage.haskell.org/users/account-management>`__.
14221447

14231448
.. option:: -u USERNAME or -uUSERNAME, --username=USERNAME

0 commit comments

Comments
 (0)