holmgr / cargo-sweep

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

`cargo-sweep` and `cargo sweep` are wonkily different #44

Closed chris-morgan closed 1 year ago

chris-morgan commented 3 years ago

cargo-sweep … and cargo sweep … should be equivalent, with the possible (but not mandatory) exception of usage information differing by that one character.

Instead, cargo sweep … is equivalent to cargo-sweep sweep …. This leads to inconsistency with well-established conventions, and the help page being confusing, with cargo sweep --help referring to cargo-sweep-sweep and talking about running the command as cargo-sweep sweep.

holmgr commented 3 years ago

I agree that this is indeed an issue, and PRs are welcome here.

jyn514 commented 1 year ago

I haven't looked at #58 in detail, but I want to mention (to @LovecraftianHorror as well) that this is pretty common for cargo subcommands, because cargo provides no way to distinguish this scenario from running a nested cargo invocation.

; cargo flamegraph
Error: could not find 'Cargo.toml' in '/home/jnelson' or any parent directory
; cargo-flamegraph
flamegraph 

USAGE:
    cargo <SUBCOMMAND>

OPTIONS:
    -h, --help    Print help information

SUBCOMMANDS:
    flamegraph    A cargo subcommand for generating flamegraphs, using inferno
    help          Print this message or the help of the given subcommand(s)
; cargo-flamegraph flamegraph
Error: could not find 'Cargo.toml' in '/home/jnelson' or any parent directory
jyn514 commented 1 year ago

I'm going to close this because cargo doesn't currently have a good way for subcommands to both accept a positional argument and support running without the first sweep subcommand. cc https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/sender/232545-jyn/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F