Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass command line arguments to stack exec

I'm building a Haskell program that uses a command line argument parser using option-applicative library. Since I'm using stack to build and test my project, I would like to execute my program passing command line arguments using stack exec, like

stack exec myprogram-exe -i myfile.txt

but when I try to execute, Stack gives me the following message:

Usage: stack exec CMD [-- ARGS (e.g. stack ghc -- X.hs -o x)] ([--plain] |
              ([--ghc-package-path] | [--no-ghc-package-path])
              ([--stack-exe] | [--no-stack-exe]) [--package ARG])

Is there a way in which I can pass command line arguments to a program executed using Stack?

like image 623
Rodrigo Ribeiro Avatar asked Sep 09 '15 14:09

Rodrigo Ribeiro


1 Answers

Something like this should work:

stack exec -- myprogram-exe -i myfile.txt

Another way as Michael Snoyman says should be like this:

$(stack exec which foo)
like image 181
Sibi Avatar answered Sep 22 '22 11:09

Sibi