Ramblings of an aging IT geek
← Ramblings of an aging IT geek
rust

a tiny cli in rust, and whether it earned its keep

Rewriting a forty-line shell script as a Rust CLI, and an honest accounting of what that bought me.

A terminal showing Rust source code

I had a shell script that munged some log files into a CSV. It was about forty lines, it worked, and every time I touched it I had to remember how awk handles field separators and then look it up anyway. So I rewrote it in Rust. Was it worth it? Mostly.

The good bits are real. clap gives you argument parsing and a --help for free, and the moment the input shape got even slightly irregular, having actual types and a Result everywhere meant the failures were named rather than silent. The old script would happily produce nonsense from a malformed line and never tell me. The new one says which line, and why.

The cost is also real. Forty lines of shell became roughly a hundred and forty of Rust, and the compile-edit loop is slower than the no-loop-at-all of a script you just run. For a one-off, the script wins easily.

What tipped it was longevity. This thing runs every night and I'd been quietly afraid of it for months. Now it's a single static binary I can drop on any box, no runtime to install, and I'm not scared of it anymore. For something I have to live with, that was worth the extra hour.