This is mostly targeted at reducing startup time for no-op commands
within *very* large applications, like deno (see #4774).
This comes at the cost of 1.1 KiB of binary size
Next-line help for possible values does not feel like its pulling its
weight. If anything we should do next-line help for the entire
argument.
This dropped about 0.5 KiB but more importantly is prep for other
changes.
This command cleaned up all the format args,
making code significantly shorter and more readable.
```
cargo clippy --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
This has been implemented for 3 years without much traction for
finishing it up.
The subcommand use case can be worked around by creating `Command`s that
just include the relevant logic, very similar to the default subcommand
examples in `git` / `git-derive`.
Using this for flags is covered by #4793.
Without `unstable-replace` being enabled, this still cut 5 KiB from
`cargo bloat --release --example git`.
Closes#2836Closes#2011
One challenge with this is finding something that generally works.
Making this work perfectly for one setting will make it inconsistent
with other settings and take up more binary size / compile time.
So in the end, I felt like just mirroring rustc (with a bit more
brevity) seemed like a decent experiment. This will be evaluated by the
feedback on release.
This is a small part of #4638
For now, we are still treating `clap` as the user facing API for both
builder and derive, making this an internal change as we don't expect
this to negatively impact builder build times all that much. We can
re-evaluate at a later time and consider having distinct top-level
crates for builder and derive.
Looking at `--timings` on my machine
- `clap` only took 0.04s to build and it happened in
parallel to `clap_builder` codegen
- this saved 1.7s for derive build times, with `clap_builder` building
in parallel to `syn` and `clap_builder` and `clap_derive` finishing
around the same time.
This was discussed some at https://rust-lang.zulipchat.com/#narrow/stream/220302-wg-cli/topic/clap.20build.20times.20and.20.60clap_derive.60.3A.20a.20crazy.20idea
We were accidentally showing long help just because a hidden argument had a description for a possible value. This is most likely to be hit with the derive API as the value descriptions are automatically applied from documentation.