You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project currently uses the clap crate for CLI argument parsing. Clap is easy to work with, concise, and provides a lot out of the box. However, it is not small (see "Size Analysis" section for more details).
As such, it might be worth investigating alternative argument parsing libraries for this project. After all, this project doesn't require anything special, just:
Using cargo-bloat we can find the functions of the executable that take up the most space. For example, of the 25 biggest functions, 15 are clap-related:
There are also features you don't use now but might want to have in the future:
Support for invalid Unicode: Out of that list, clap and lexopt and xflags can handle it. You don't get it for free, you'd have to switch from String to OsString/PathBuf, but it's useful for an rm to be able to delete files with problematic names.
argh doesn't support the --interactive=once and --preserve-root=all syntax of GNU rm, and some of the other parsers might not either. (In clap this is require_equals, in getopts this is optflagopt, in lexopt this is optional_value.)
Thanks for chiming in @blyxxyz, the benchmarks are very useful and so are the other suggestions. In fact, I created an issue to support invalid Unicode paths. I also added the considerations to the issue description as (for now) potential requirements.
Technical Change
Summary
This project currently uses the
clap
crate for CLI argument parsing. Clap is easy to work with, concise, and provides a lot out of the box. However, it is not small (see "Size Analysis" section for more details).As such, it might be worth investigating alternative argument parsing libraries for this project. After all, this project doesn't require anything special, just:
Requirements
--recursive
)-r
)-rf
)--interactive=WHEN
)--
)foo.bar
)OsString
(or similar) argumentsAlternatives
clap
without the derive feature1Using the(unmaintained)docopt
crateUsing the(maintenance mode)structopt
crategetopt
crate (used byrustc
)lexopt
cratexflags
crateargh
crateSize Analysis
Using
cargo-bloat
we can find the functions of the executable that take up the most space. For example, of the 25 biggest functions, 15 areclap
-related:More stats
N=10
4 of the 10 biggest function are related to
clap
:N=50
26 of the 50 biggest function are related to
clap
:N=100
37 of the 100 biggest function are related to
clap
:Footnotes
Based on https://github.com/rosetta-rs/argparse-rosetta-rs/tree/ec59407e70cb8993f9a81f8b2c3df1397fe84422#results derived code is less optimized for size. ↩
The text was updated successfully, but these errors were encountered: