Finish off the external commands feature
commitd8ebb8146f36ad0809c93940e888fda88dd329e1
authorMatthew Pickering <matthewtpickering@gmail.com>
Mon, 6 Nov 2023 11:01:34 +0000 (6 11:01 +0000)
committerMikolaj <281893+Mikolaj@users.noreply.github.com>
Fri, 24 Nov 2023 15:22:48 +0000 (24 15:22 +0000)
tree816d074d804da3c8047ed7290c50e3a0e7c00599
parent7fb1ca65009a91daa27c67893959ee041233f3d9
Finish off the external commands feature

* Remove 'CommandDelegate' in favour of abstracting the fallback in
  'commandsRun', there is a new variant 'commdandRunWithFallback' which
  takes a continuation
  - This restores the modularity between the `Cabal` library and
    `cabal-install` as now `Cabal` doesn't need to know anything about
    the external command interface.
  - Fixes #9403
* Set the $CABAL environment variable to the current executable path
  - This allows external commands to be implemented by calling $CABAL,
    which is strongly preferred to linking against the Cabal library as
    there is no easy way to guantee your tool and `cabal-install` link
    against the same `Cabal` library.
  - Fixes #9402
* Pass the name of the argument
  - This allows external commands to be implemented as symlinks to an
    executable, and multiple commands can be interpreted by the same
    executable.
  - Fixes #9405
* `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external
  commands.
  - This allows the `help` command to also work for external
  commands and hence they are better integrated into cabal-install.
  - Fixes #9404

The tests are updated to test all these additions.

These features bring the external command interface up to par with the
cargo external command interface.
15 files changed:
Cabal/src/Distribution/Make.hs
Cabal/src/Distribution/Simple.hs
Cabal/src/Distribution/Simple/Command.hs
cabal-install/src/Distribution/Client/Main.hs
cabal-install/src/Distribution/Client/SavedFlags.hs
cabal-testsuite/PackageTests/ExternalCommand/cabal.test.hs
cabal-testsuite/PackageTests/ExternalCommand/setup-test/AAAA.hs
cabal-testsuite/PackageTests/ExternalCommandEnv/cabal.test.hs
cabal-testsuite/PackageTests/ExternalCommandHelp/cabal.out
cabal-testsuite/PackageTests/ExternalCommandHelp/cabal.test.hs
cabal-testsuite/PackageTests/ExternalCommandHelp/setup-test/AAAA.hs
cabal-testsuite/PackageTests/ExternalCommandSetup/setup.cabal.hs
cabal-testsuite/PackageTests/ExternalCommandSetup/setup.out
cabal-testsuite/src/Test/Cabal/Prelude.hs
doc/external-commands.rst