So far I didn’t find anything related in Cargo’s source (this is where all the CLI goes). To clarify I want to know how cargo web works. How does cargo-web.exe runs as a subcommand in cargo if it’s not a built-in one?
It looks like my GitHub issue won’t be answered too and I’m not wanting to waste time again like my threwn away parsers.
If I’m reading the source correctly, cargo matches on clap errors and if it’s an unrecognized subcommand, it will try to execute an external binary cargo-<subcommandname>:
and execute_external_subcommand:
There’s probably more to it than just this, but the rest can probably be found by digging around in cargo’s source searching for usages of execute_external_subcommand and the like?
if let Err(err) = result {
match err.kind {
ErrorKind::UnrecognizedSubcommand
| ErrorKind::UnknownArgument => {
let name = &err.info.unwrap()[0];
println!("Probably air");
return;
},
_ => {
if err.use_stderr() {
err.exit();
}
return;
}
}
}