rustsec icon indicating copy to clipboard operation
rustsec copied to clipboard

Non-0 exit code if no subcommand is specified

Open threema-danilo opened this issue 4 years ago • 3 comments

I think a few versions ago, the way to invoke cargo-audit was cargo audit.

By now, the API was changed, and it's now cargo audit audit.

Unfortunately if no subcommand is specified, the exit code is 0. So in a lot of my CI configurations, the command would just exit successfully without actually running the audit checks on my code.

Could we exit with a non-0 exit code if no subcommand is specified, to avoid this situation and alert people that updates in the calling style are required?

threema-danilo avatar Mar 11 '21 17:03 threema-danilo

Oh, I just noticed that this only happens if the command is invoked directly through the binary (cargo-audit), but not when invoked through cargo. So it will probably only affect a few of the setups. Nevertheless, I think a non-zero exit code would be beneficial, for the people that accidentally use cargo-audit instead of argo audit.

threema-danilo avatar Mar 11 '21 18:03 threema-danilo

Nothing particularly notable has changed here recently, although I can look into this

tarcieri avatar Mar 11 '21 18:03 tarcieri

After re-reading my second comment, I think it wasn't quite clear. The invocation is either cargo audit or cargo-audit audit (and not cargo audit audit as I wrote initially). I did not realize that I was accidentally using cargo-audit instead in CI, which simply prints the usage information but does not actually audit the code.

This could be avoided if running cargo-audit would print usage, followed by a non-0 exit code.

threema-danilo avatar Mar 11 '21 18:03 threema-danilo