Why doesn't rust have bin-dependencies?
I have a very simple crate and a cli that uses clap, but if others just use it as a library, then there is no need to install clap. I found some ways to avoid this problem, but none of them are perfect.
It seems that someone proposed it as early as 2015. https://github.com/rust-lang/cargo/issues/1987
Here are three solutions
https://stackoverflow.com/questions/35711044/how-can-i-specify-binary-only-dependencies
Turn the binaries to examples
This is suitable for testing, but not for publishing to crate.io for others to use. In addition, bin cannot specify a path, so you need to run it in the example way.
cargo run --example abc
Make the binaries as its own package
This is by far the simplest and works best, but I would like the crate and cli names to be same.
use abc
cargo install abc
abc --version
Optional dependencies with required features
This is the method I currently use. Everything is perfect except that I need to add features at runtime.
cargo run --features build-binary
It's not clear to me what's blocking bin-dependencies, is it because there could be multiple bins?