holmgr / cargo-sweep

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

Accept more than one project #95

Closed marcospb19 closed 1 year ago

marcospb19 commented 1 year ago

Currently, cargo sweep accepts one optional and positional argument as path to the project to sweep.

It would be good to have it accepting multiple paths.

cargo sweep [OPTS] project1 project2 project3

cargo-sweep is already capable of sweeping multiple projects (see --recursive implementation), so this should be easy to implement.

jyn514 commented 1 year ago

Mentoring instructions: Change https://github.com/holmgr/cargo-sweep/blob/475ac9ec16518596fc21cb2ea77bd8045b5a4a6d/src/cli.rs#L39-L40 to a Vec instead of Option, then change https://github.com/holmgr/cargo-sweep/blob/a36602ffb06c2b62f35d246e22dc33b5163a69b0/src/main.rs#L154-L160 to support multiple paths. I think everything else should "just work".

social-anthrax commented 1 year ago

I've added some basic support but it only writes the timestamp into the first path. I'm assuming this isn't expected behaviour but I can't say i've used it enough to know what would be correct.

jyn514 commented 1 year ago

@social-anthrax that's amazing, thank you! I think for now we can give a hard error if you try to combine --stamp with either --recursive or multiple projects.

social-anthrax commented 1 year ago

Recursive should still work fine as it'll save it to the root. I've added a check to make sure --stamp isn't set when multiple paths are passed.