from Hacker News

Clap 3.0, a Rust CLI argument parser

by arusahni on 1/1/22, 1:30 AM with 4 comments

  • by alkonaut on 1/1/22, 11:06 AM

    How much overhead does Clap add to a small console app now? Both in terms of compile time and binary size.

    Or put another way, is there a minimum size an app should be before Clap is added, if you don’t want Clap to be the majority of the binary and compile time?

    I think I remember trying an early version and it was painfully large then but maybe it has changed.

  • by vlmutolo on 1/1/22, 6:20 AM

    Clap (+structopt) is such an amazing tool that it's one of the core reasons I prefer Rust-made CLIs: the help messages and descriptions make sense to me. Basically every Rust CLI project will use clap/structopt, and the consistency wins are also great.

    I'm interested to see whether people will continue to use structopt (which is a high-level macro interface on top of clap), or if they'll just use the new macro features in clap itself.

  • by johnisgood on 1/1/22, 5:32 PM

    The output of "cargo run -- --help" does not make much sense to me. "-h" is an option? What about "-v"? Why is it not called an option? Or it is an option that belongs to "DEBUG"? What is "--config" exactly, a mandatory option? Based on "test-clap [OPTIONS] --config <CONFIG>", it seems to be the case, otherwise it would belong to "[OPTIONS]", right? I would rather just read the manual page of "test-clap", hoping that they are sticking to conventions and whatnot.

    We need consistency. I try to stick to https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1.... Sometimes I do have "commands" or "sub-commands".