I always wanted a better CLI for Transity, but I don’t like applicative CLI option parsing. (The applicative interface feels kind of “forced”. I can’t see how this makes building a CLI easier or better.) The one it had was just some bare bones, cobbled together, manual arg parsing.
I tried to revive Neodoc (based on docopt - a WYSIWYG kind of way to describe CLI interfaces), but I never finished it. Also, I realized that it didn’t quite support the features I wanted.
Over the last few weeks, I finally found the time and motivation to build the tool I envisioned.
Let me introduce you to Oclis, the “Obvious CLI Specification Format”
It works like this:
-
cargo install oclis
- Install Oclis globally -
oclis init
- Creates anoclis.ncl
specification file in the root of your project. - Adapt the specification file to your liking.
- Examples directory for inspiration
- Nickel Language website
- Run
oclis build
to generate the CLI parsing code insrc/Oclis
- Define the handler functions for your commands in your
Main.purs
(Check out the main function of Transity for an example.) - Build and use your project as usual
Long term goals:
- Support for more languages (JavaScript, Rust, Haskell, …)
- Also read config files and environment variables during execution
- Create more performant code
- Don’t use intermediate JSON, but directly create the CLI Spec type
- And a big maybe: Directly create a GUI apps from the same specification.
(I love PureScript’s Flare and Sparkle for this.)
It’s still rough around the edges, but I wanted to hear your feedback rather sooner than later.
Also:
Any contributors would be highly appreciated!
There is a lot of work to be done until it becomes the all encompassing CLI generation tool I envision and I can’t do it alone!