Newbie question: What’s a good approach to writing CLI programs in PureScript? I know PS is quite a bit geared towards the web, but CLIs via Node shoudl be possible too.
I found a package (natefaubion/purescript-argparse-basic) for it and a blog post (Write a simple CLI in PureScript) describing how to do things by hand.
However, are there other libraries helping with building CLIs? Maybe there is even some kind of a “standard” package?
Thanks for pointers!
I don’t think the community has quite yet arrived at a “standard” package. I’m under the impression that optparse
is the most popular, but I could definitely be misguided there.
You might be interested in chapter 11 of the PureScript book, which steps you through writing a very simple CLI game, though it’s close to the end of the book and builds on pretty much all the topics that came before it, so the learning curve can be steep if you’re just getting started with PureScript.
(Also, word of warning: the docs for optparse were originally written for Haskell, and in some spots the syntax isn’t translated quite correctly for PureScript - especially where records are involved. If you’re getting weird compile errors while working through the optparse docs, it might be the documentation’s fault and not yours. Please ask if any errors don’t make sense to you!)
1 Like
Thanks for the link to optparse
. Will check it out.
I’ve made a few purescript applications for node. Optparse is very nice, but also highly structured (e.g. not monadic). Don’t discount the fact that you have the FFI at your fingertips, too, so you can always work with process.argv
directly or any javascript argument-parsing library.
1 Like