Roll- A Little Dice Roller

I needed to roll some dice and didn't want to open a browser tab.

So I wrote roll, a tiny command line dice roller in Nim. No config, no network, no database — just parse a string, throw some random numbers, print the result. That's it.

$ roll 2d6
2d6: 4 + 3 = 7

$ roll 1d20+5
1d20+5: 14 + 5 = 19

$ roll 4d6k3
4d6k3: 5 + [2] + 3 + 5 = 13

Notation is the standard tabletop kind: NdS, plus modifiers (+3, -2), keep-high/low (k3, k1l), exploding dice (!), and Fudge dice (dF). Dropped dice show in brackets, explosions get a !. Nothing fancy, nothing missing.

I went with Nim because, well, it's Nim — compiles to a single binary you can drop anywhere, starts instantly, and the standard library has everything. I used cligen for argument parsing because I use it for everything and it Just Works. Parser is a hand-rolled little state machine because the grammar is simple enough that pulling in a full parser generator would be silly. Tests with unittest, build with nimble, the usual drill.

The whole thing is maybe a couple hundred lines. It took an afternoon. I could have used an online roller, but now I don't have to, and there's something deeply satisfying about a tool that does exactly one thing and then gets out of the way.

Grab it from github.com/capocasa/roll and build with nimble build if you want it.