Follow

Thinking about re-writing my clunky Rust command line tool[1] using clap.rs[2], in the hopes of (a) learning something, (b) making it more useful to users, and (c) making it easier for others to contribute.

Do any of y'all have clap.rs tutorials/examples you like? (Beyond the examples included in the repo itself, which I will try to learn from)

(1) github.com/sts10/medic
(2) github.com/clap-rs/clap

@schlink I have a recommendation, which is not something you've asked for, but nevertheless :D

Use docs.rs/structopt — it's a higher-level wrapper over clap that gets you much more "ADT-like" (and so, Rust-like) than "query-like" arg parsing. You're going to love it and wish other languages had this 😃

@bugaevc @schlink

Hmm, I hadn't heard #clap versus #structopt compared like that—I'd thought of structopt as the easier-to-use-but-less-flexible alternate and had never tried it.

Hard to imagine a better library than clap—I *really* like it!—but maybe I should try structopt some time

@codesections @schlink see, I don't think of it as a "versus"/"alternative", I think of it as of another, more ADT-focused interface to clap. You're still using clap, just with a wholly different API.

@schlink

> Do any of y'all have clap.rs tutorials/examples you like? (Beyond the examples included in the repo itself, which I will try to learn from)

No tutorials come immediately to mind, but here's my implementation of a pretty simple CLI for my mnemonic app.
github.com/codesections/mnemon

I'm also happy to answer any questions as they come up—I'm a big fan of #clap

@schlink depending on how much control you need, you might want to check out structopt first -- it uses clap under the hood, but exposes a more declarative API

crates.io/crates/structopt

Sign in to participate in the conversation
Octodon

Octodon is a nice general purpose instance. more