An external command system for cabal: what would you do with it?

We have a pattern for what it should do without an argument as well. Without an argument cabal v2-build builds either the library by the same name or the executable (I think). Add should default to this. If it is ambiguous, you could warn the user:

Adding <dependency> to <default>. To explicitly do this use “cabal add <same dependency> <actual default>”
To add to other libraries/executables in this package use:
”cabal add <same dependency> <other option>”
”cabal add <same dependency> <other option>”
”cabal add <same dependency> <other option>”
… (ellipsis if there are more than k options (5?))”

For the record, that’s pretty much exactly what cabal-add does: it will make its best to figure out the “default” component, but also accepts a target (in a format as reported by cabal-3.16.0.0 target) to disambiguate.

1 Like

The new cabal target command is included in the cabal-install-3.16.0.0 release.

2 Likes