is it possible to make program aliases in `stack exec`?

Viewed 149

I have a project that has many small executable targets. It takes quite a lot of time whenever the source code changes due to the problem that you cannot avoid building every executables in the project.

So instead I'm trying to have one single executable who decides its own behavior by checking its name (perhaps by using getProgName): for example, I can build a single executable name foo, and two soft links targeting at it, one called progA and another progB: I want it to behave like there are three separated programs:

  • foo [progA|progB] print help messages when arguments are missing, or run as if it's progA or progB if foo is equal to either of them
  • progA & progB: as if there are separated binaries

As I don't want my project executables to be exposed globally, what I usually do is just stack build && stack exec -- <progName> [...args]. My question is: is it possible to have one single executable (namely foo in my example) in .cabal file, while stack does something under the hood to make available stack exec -- progA and stack exec -- progB?

I know I could get and parse PATH from the environment in which stack exec runs, and make soft links accordingly there, but I'll prefer a less hacky method.

0 Answers
Related