Today I'd like to go over a simple Rust CLI application I made. It is set up with just one simple command, however it is organized to scale to many different commands. Please feel free to use it in your own work. If you have any suggestions, please send me an email - email@example.com.
The technologies I'm using today are below
Rust CLI Example App Overview
The project is organized into a few sections
│ ├── js_to_ts.rs
│ └── mod.rs
src we have the
main.rs holds the application orchestration code. You'll see some code that translates string input to a Command. The program first runs some setup code to configure logging and error reporting. After that, it parses the CLI input and runs the appropriate command.
The final file of note is the
js_to_ts.rs file under the
commands folder. This is all the code that runs when the command is selected. The file here shows a simple command that searches a folder recursively and changes any files with a
.js extension to a
.ts extension. It uses
tokio tasks to leverage some system concurrency.
Checkout the full source and give it a ⭐ on Github if you've found it useful. Thanks for reading! 📖