This makes them impossible to unit-test and necessitates manual calls to eprintln_help() in multiple places instead of just one in main on any validation error.
We should split argument validation to another function that accepts Args and returns Result<ValidatedArgs>, where ValidatedArgs is something like:
Right now argument validation and actually calling the subcommands is lumped together in one function:
https://github.com/rust-secure-code/cargo-supply-chain/blob/776ab090333f4f07a61fe0e66386e49bae5eff45/src/main.rs#L65-L67
This makes them impossible to unit-test and necessitates manual calls to
eprintln_help()
in multiple places instead of just one inmain
on any validation error.We should split argument validation to another function that accepts
Args
and returnsResult<ValidatedArgs>
, where ValidatedArgs is something like:And make
dispatch_command
accept that as an argument.