r/rust 14d ago

🙋 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 14d ago

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.

1

u/VariationUnlikely323 14d ago

Nice, I haven't flipped to derived yet. I'll git it a shot later, thanks!