holmgr / cargo-sweep

A cargo subcommand for cleaning up unused build files generated by Cargo
MIT License
729 stars 31 forks source link

Allow `--maxsize` to accept byte size units #82

Closed marcospb19 closed 11 months ago

marcospb19 commented 1 year ago

I was making a contribution when I found this:

https://github.com/holmgr/cargo-sweep/blob/75414ca5dfd138691031c6f701fbaa350fd5b095/src/main.rs#L263-L273

This TODO note is suggesting that we allow the --maxsize flag to expect common byte-size units, like "300 MB", "10GB" and "10 GiB".


The parse-size crate already implements the parsing needed to make this work.

EDIT: Oops, seems like we are already using human_size::Size to do this kind of parsing. EDIT2: Note that humansize and human-size are two different crates.

jyn514 commented 1 year ago

We are using human_size in tests only right now. I think parsing user input is reasonable, though, I would take a PR for that.