Looking for opinions and suggestions on a CLI library project

Hi everyone, recently @AndrewCodeDev and I made a very cool library called Fluent. Now we are approaching maturity, but I want to test it for myself and see if everything feels right. In order to do that I’ve settled on building a small CLI library, which I’ve never done before, so, I’d like to request some of your experience and knowledge, in order to make it decent. So here are my questions for you. What do you expect from a CLI library ? Argument parsing seems obvious, but are there other stuff that seems important to you ? What’s the kind of API you would like to find ? Do you know any good project that I can take inspiration from ? if you have any other suggestions feel free I’d love to hear about it.


I think a way to easily colour and format text would be nice, so a collection of escape sequences


I think the main question here would be, “What even is a CLI library?”
Besides just handling argument parsing, the requirements can diverge greatly.
TUI, interactivity, repls, promts, user input, progress bars, etc

Here are things I have used in the past:
all the ansi color things: colorama · PyPI
Clickable hyperlinks: crates.io: Rust Package Registry
Elaborate error reporting: crates.io: Rust Package Registry

1 Like

Ok good, I can make a custom writter with nice options for formatting and coloring, that’s a good idea, do you know of any “standard” that exist to propose such features ? Or is it really implementation dependant ?

Euh afaik there isn’t really one besides a writer, which is perfectly fine imo

1 Like

Well the way I see it at least, a small CLI library, should provide at a bare minimum simple CLI argument parsing. be fairly simple in terms of API, and then the rest is really up to the implementation to decide what to bring to the table, so for example nice formatting is cool, I’d like to provide a way to list directory to search, and maybe some other stuff, I’m not so sure yet, that’s why I’m asking if anyone as interesting suggestions or request to make. :slight_smile:

Yes but for the colors, how do you do that, do you use escape sequence just like C or is there some other way to do it ?

Yes, just like in C you can print an escape string to the stdout and it will change colour, cursor position, etc etc

Personally id do it like i did here: unicode-renderer/src/tty.zig at main - segfault-enjoyer/unicode-renderer - Codeberg.org

This has the advantage that you can store colours etc. very space efficiently and with predictable memory usage allowing you to avoid allocations in some cases and you can just do mycolour.get_code() before using the writer. (I know i wasnt using this colour thing in my project, its just a file i carry around with me when i want to do tui stuff, so yea, the advantages I listed earlier arent made use of here)

1 Like

Ok thanks for the suggestions, I like the way of doing it just like C, plus that makes it more portable too.

Have you thought about writing an application over another library? What sorts of applications do you think you might enjoy working on?

1 Like

To be fully transparent, in about a year I have a big project in mind that I want to create, which will require some form of CLI library, so this is a library that I intend to use, just like Fluent.

Basically to explain the project I have in mind in the future :

I’m in a programming school where you don’t have any teachers or classes, everything works on a peer to peer model, and it’s 100% project based. In order to make progress in the school, you have to complete projects, each project, has some requirements you have to follow. Once your project is done you can spend some virtual tokens to ask other students to review and test your code and to acquire those tokens you have to review other’s code too. You need 3 review before your project is considered done. In order to make the correction process easier, it’s very common to use some “testers” which are projects that are made by former students and that you can now use freely.

The problem with those testers is that they lack consistency, and portability. For the first year of my school everything is done in C and only C. So some testers only work on Linux, while other only work on MacOS. Some will report memory leaks on Linux but not on MacOS due to the lack of valgrind on the platform. Some are made in C++ or bash and are hard to decipher, some have weird ways of testing your code, etc.

Basically what I would like to do in about a year, is to take the time to rewrite as many testers as I can in Zig, to take advantage of the fact that Zig offers cross-compilation, and that Zig is the language that works the best with C that I know of. So this is the reason I’m trying very hard to build some tools in Zig right now, it’s because this project is quite big, and the more tools I can build and test upfront the easier my job will be in the future. Especially because my next next big project to get my master degree, is a Unix Kernel implementation (where I will also use Zig) so again the more tools the better.