Reputation: 6244
Is there a simple recipe or library for creating a subcommand command line utility in Haskell?
E.g. git log
for logging, git status
for status et cetera. Something like Python's argparse's support for subcommands would be fantastic.
Upvotes: 4
Views: 479
Reputation: 64740
Do you know about hackage? Just look for args
and you see cmdargs
(easy to use, arguably the most popular solution), parseargs
(less magic, might actually work with a non-GHC compiler, also easy to use), and simpleargs
(I've not used this one). Others are probably out there, but you should look at the haddock documents and decide which one seems most fitting for your needs.
Upvotes: 1
Reputation: 179179
I haven't used it myself yet, but take a look at the CmdArgs package.
Upvotes: 5
Reputation: 17537
Write one simple main application that only checks for its first argument string, and delecates basing on that. It will pass the subsequent arguments to the program that actually handles the requests (the log
or status
). Group common functionality in modules to be available and you already have a tidy framework to write new "modules" as they sometimes are called.
Upvotes: 0