First Rust & CLI tool "Leaper"

Hello all,

I'm excited to share my first complete Rust project with you all and would greatly appreciate your feedback and suggestions. As a newcomer to Rust, this project has been an incredible learning experience and elevated my understanding of the language significantly, although it's probably only like 10% of what is there to know :smile:.

The project is a simple CLI tool that allows you to quickly switch or "leap" to a folder or file, more details in crates.io: Rust Package Registry.

Enjoy your weekend!
Cheers,
Michael

Those kind of cli tools generally have a two steps approach. Your binary should prints the desired path or exit with a an error and the user should add a shell alias or function calling your binary and using its output to actually change directory.

You're currently spawning a new (bash) shell everytime.

2 Likes

The project was mostly to learn Rust, when I run into the technical limitation I opted for the easiest option. I did not review other similar tools or how to avoid the shell spawning.

You are obviously right to point this out, I should have mentioned this and will add it to the readme, and thank you for your feedback and the example, very helpful!

Any feedback on the code itself?

Code itself is fine, I would encourage you to use the type system more, eg: using clap's derive API, not returning an empty pathbuf but an option instead. Algorithm note: search a stream of paths instead of collecting the paths then search among them. Also lots of your functions are pretty tangled with each other, I'd advise to make them take inputs and return outputs instead of mutating internal state.

1 Like

Appreciate the feedback, this is very insightful, thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.