I'm trying to use optparse-applicative to parse a Maybe String but I can't find anywhere how to deal with Maybe. The only thing I found is to add a default value but I really need a Nothing if user didn't supply an option instead of "". Is there any…
Consider the following type signatures:
data Foo x = Foo {
name :: String
, reader :: String -> x
}
instance Functor Foo where
fmap f (Foo n r) = Foo n $ f . r
Now I show a natural transformation from Foo to optparse-applicative's Parser…
Is possible to create a haskell expression, using the methods in optparse-applicative, that parses program options like this?
program [-a [-b]] ...
-a and -b are optionals flags (implemented using switch), with the constraint that the -b option…
In my Haskell executable, created using optparse-applicative, I would like to have a global option for --version alongside the global --help option that is available from all subcommands. However the example provided (see below) for adding a…
I am attempting to use Hackage's optparse-applicative package and have a question regarding how to specify a certain aspect of the help message displayed when the program is run with insufficient commands specified.
The following example program…
I'm building a brainfuck compiler. The executable accepts two commands $ brainfuck compile ... and $ brainfuck run. I want the executable to auto complete when pressing tab. E.g. writing $ brainfuck com and then pressing tab should generate $…
I just found out that my carefully crafted parser fails to parse any string I throw at it:
roi :: Parser (Maybe ROI)
roi = optional $ option (ROI <$> auto <*> auto <*> auto <*> auto)
$ long "roi" <> metavar "ROI" <> help "Only process…
I'm trying to use the optparse-applicative library in an program which should perform a different action depending on the number of arguments.
For example, the argument parsing for a program which calculates perimeters:
module TestOpts where
import…
I would like to add synonyms for the subcommands in my Haskell command line tool. For example summarise and summarize should yield the same result. Of course I could just add an entirely separate command summarize, that appears as an own element in…
I'm a Haskell newbie. As a learning exercise, I'm trying to port one of my Rust programs to Haskell. In Rust, I use the amazing clap package, and have come across Options.Applicative as a good-looking alternative. Here's an example:
import…
How do I implement a parser for this example from grep --help:
--binary-files=TYPE assume that binary files are TYPE;
TYPE is 'binary', 'text', or 'without-match'
Assuming that I have
data BinaryFiles = Binary | Text |…
I'm trying to parse a list of pairs with optparse-applicative. Parsing a single pair works, but parsing arbitrarily many using the many combinator fails.
import Options.Applicative
pairParser = (,) <$> argument str (metavar "s1")
…
I'm trying to rewrite the automatically generated help output from optparse-applicative.
Following code lets me replace the help output:
import Options.Applicative
import Data.Semigroup ((<>))
data Opts = Opts { optFast :: Bool, optHelp :: Bool…
So I'm not exactly sure whether this is something wrong with optparse-applicative's script or if I'm using it wrong.
In the optparse-applicative readme, it states that programs are made available with automatic completion scripts, with options for…