Rust Router tool
a library for building command line applications.
- Rust
Why
A command line program is a classic and powerful type of tool at the heart of many an automation. Most programming languages have modules for making these easy to build.
Having built many Web and API projects, I was dreamin' up several tools I'd want to build to smoothen out some of the experiences I didn't like. I explored the most recommended options, but was not as enchanted as others were.
I built Rou to be easier to design APIs, and use less disk space, less memory at runtime, and less third-party dependencies. I put a lot of care into the last two points, because the library is a foundation applications build on and needs to be as little a weight as possible to the business logic.
Many projects rely on a number of dependencies for their business logic, and the code necessary to lay the foundation before business logic should be the first code to go on a diet.
How
The purpose of Rou is to take in a path to some function the program provides, along with options for that function, and route it to the desired function. Much like HTTP APIs.
The machinery necessary to facilitate this has a data-oriented design to minimize the bytes wasted for padding in memory. The library's API was designed to be readable, and reflects the nestable nature of commands. This is optimized at compile time in Rust using procedural macros and const functions.
- I created a small program, countcmd, to see if a certain optimization was worth it. - Several alternative experiments