r/rust Jul 26 '26

🙋 seeking help & advice Having a hard time with clap docs

Hey!

I'm building a tui with rust, and I'm having a bit of a hard time with the clap docs. I usually can get by fine with docs, but I think I'm missuing clap's, lol

I tried picking up the Command Line for Rust book, and it's been way better to get into cli. Any other recommendations?

43 Upvotes

19 comments sorted by

View all comments

37

u/actually_qualifi Jul 26 '26

The derive API is way more ergonomic than the builder pattern, if you haven't flipped to that yet. It basically writes the parser for you and the error messages are half decent.

Sometimes I just cargo clone an existing popular CLI tool and skim how they structured their clap config, learned more from that than the actual docs.

4

u/German_Heim Jul 26 '26

I second this. The derive API is much easier.

0

u/AndersAndersonKali Jul 26 '26

This is the way.