Prism: CLI Library (inspired by Golang's Cobra)
Prism
This is a library for building CLI tools written purely in Mojo! It's inspired by the
Cobra
package from the Golang ecosystem.
https://github.com/thatstoasty/prism
eg
4 Replies
How far along are you on this?
Fairly far along at this point, if you check out the readme headers you'll be able to glance through the implemented features. The API might change slightly as I tweak things for an easier developer experience.
Open to contributors if anyone wants to jump in 🙂
cool, in your description could you also elaborate on what Cobra is doing or more directly, what are you trying to accomplish?may not be easily appreciated by the majority who dont know what cobra is
@jmky will do, I’ll remove that bit so it’s not confusing. The library was modeled after a the golang CLI package named Cobra.
Prism is a package to build CLI tools with in Mojo, so it would help to clarify that in the description!
Prism has been updated for Mojo 24.4!
Due to changes with how Arc works, and with self references or lists of references being difficult/impossible. I had to modify the flow for a user a bit.
For example
Commands must be turned into an Arc[Command] when initially created. This is so the relationship between commands can be preserved when you call
add_command
.
Also, modifying a commands flagset through command methods has been removed. Users should alter a command's flags through the flags field(s) directly. Like so