ANNOUNCE multiarg - parser combinators for command line parsing
multiarg is a parser combinator library to build command line parsers. With it you can easily create parsers with options that take more than one option argument--for example, I created multiarg due to the apparent lack of such ability amongst other parsers. Its basic design is loosely inspired by Parsec. Provides ParserT, a monad you use to build parsers. ParserT is a monad transformer, so you can layer it on top of other monads. For instance you could layer it on the IO monad so that your parser can perform IO. It also has a simple, pre-built parser built with the underlying combinators, which works for many situtations and shields you from the underlying complexity if you don't need it. Any feedback you might have is much appreciated. You can email or fork it on github. The Haddock comments are extensive so those should be able to get you started. multiarg on Hackage: http://hackage.haskell.org/package/multiarg multiarg's git repository: https://github.com/massysett/multiarg
Hi Omari, I'm currently using Neil Mitchell's cmdargs package [1]. How does your package compare to that? best regards, Simon [1] http://hackage.haskell.org/package/cmdargs-0.9.2 2012/1/29 Omari Norman <omari@smileystation.com>:
multiarg is a parser combinator library to build command line parsers. With it you can easily create parsers with options that take more than one option argument--for example, I created multiarg due to the apparent lack of such ability amongst other parsers. Its basic design is loosely inspired by Parsec.
Provides ParserT, a monad you use to build parsers. ParserT is a monad transformer, so you can layer it on top of other monads. For instance you could layer it on the IO monad so that your parser can perform IO.
It also has a simple, pre-built parser built with the underlying combinators, which works for many situtations and shields you from the underlying complexity if you don't need it.
Any feedback you might have is much appreciated. You can email or fork it on github. The Haddock comments are extensive so those should be able to get you started.
multiarg on Hackage:
http://hackage.haskell.org/package/multiarg
multiarg's git repository:
https://github.com/massysett/multiarg
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
I'm currently using Neil Mitchell's cmdargs package [1]. How does your package compare to that?
Hi Simon, If you're using cmdargs and you're happy with it, you should certainly stick with it, as it certainly has many capabilities that multiarg does not, as well as being much better tested :) I examined cmdargs before writing multiarg; the main reason I decided to write something myself is because cmdargs offers no (apparent) way to create options that take more than one argument, such as "--pair thing1 thing2". Some programs do have options that really take more than one logical argument but, as far as I can tell, most of them resort to tricks such as putting both options in a single word and using characters such as : or = to delimit them. (mplayer is a good example of this.) I figure that the shell already does the hard work of splitting things into words, so the parser should be able to parse options that accept more than one word as arguments. multiarg aims to be modular, like a parser combinator library. By taking a few simple pieces you can build very complex parsers. For instance, there is no explicit support for multiple-mode commands (e.g. "darcs whatsnew", "darcs send", etc.) multiarg does not need such support because there are a couple of parsers (nextArg, nonOptionPosArg) that can be easily used to parse modes, arguments to options, or positional arguments. cmdargs does a lot of things that multiarg will never do--for instance, it creates help automatically and even creates zsh completions automatically. This is a nifty feature but I always find these sort of things frustrating and I would rather just write the help in a text editor. For a sample module that uses multiarg, see Pantry: https://github.com/massysett/Pantry/blob/master/Pantry/Parser.hs --Omari
participants (2)
-
Omari Norman -
Simon Meier