optparse-applicative icon indicating copy to clipboard operation
optparse-applicative copied to clipboard

Option/flag polymorphism

Open trillioneyes opened this issue 12 years ago • 1 comments

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?

trillioneyes avatar Feb 22 '14 02:02 trillioneyes

On second thought, I asked this question prematurely. I think I can see how that would work now.

trillioneyes avatar Feb 22 '14 03:02 trillioneyes