optparse-applicative
optparse-applicative copied to clipboard
Option/flag polymorphism
Idris, an existing program, has an option called --exec that works like this:
idris --exec 'putStrLn "hello"'
hello
However, if --exec is the last command line argument, it is instead interpreted as a flag that means "run this file instead of starting the repl or compiling it" (more specifically, it is equivalent to --exec 'Main.main'):
-- main.idr
module Main
main = putStrLn "hello"
idris main.idr --exec
hello
Is there a way to get this behavior in optparse-applicative?
On second thought, I asked this question prematurely. I think I can see how that would work now.