commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

ls dependencies, accepts but does nothing with two commands #6591

Closed philderbeast closed 1 month ago

philderbeast commented 1 month ago

I can trip up stack ls dependencies so that it doesn't output any dependencies by giving it a combination of 2+ output formats ("Available commands"):

$ stack --version
Version 2.15.7, Git revision 75bb479f04755c1daf91ec8f445e17e2ba2ab7a3 x86_64 hpack-0.36.0

$ stack ls dependencies --help
Usage: stack ls dependencies [COMMAND ...]
...
Available commands:
  text                     Print dependencies as text (default).
  cabal                    Print dependencies as exact Cabal constraints.
  tree                     Print dependencies as tree.
  json                     Print dependencies as JSON.
$ stack ls dependencies json text
$ stack ls dependencies tree json text cabal
philderbeast commented 1 month ago

We get no output with non-existent output formats:

$ stack ls dependencies toml
$ stack ls dependencies yaml

We get no output with a valid command followed by junk;

$ stack ls dependencies text lorem-ipsum
$ stack ls dependencies lorem-ipsum
mpilgrem commented 1 month ago

It is not well documented (especially in-app), but TARGET can be specified multiple times - https://docs.haskellstack.org/en/latest/build_command/#target-syntax.

If a specified target (eg lorem-ipsum, toml, yaml, text, cabal - as in your examples) does not exist in a project, then there are no dependencies to list.

An alternative would be to throw an error, but the design choice is to return a null result.

EDIT: The online help for each of the sub-sub-commands is here: https://docs.haskellstack.org/en/stable/ls_command/#the-stack-ls-dependencies-command

mpilgrem commented 1 month ago

The documentation has been improved, online and in-app.