How to create a cli that operates as a cargo plugin #5561
-
I'm trying to build a simple CLI tool that should be able to be used as a cargo plugin. As such my tool could be invoked as
Specifically this seems to consume any first argument that doesn't match a subcommand, which leads to less than clear error messages when a typo is made in that subcommand. ie |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
We have an example of a cargo plugint https://docs.rs/clap/latest/clap/_derive/_cookbook/cargo_example_derive/index.html Sounds like you are wanting it to work standalone and as a plugin. I generally recommend against that. If you still want to do it, check out our |
Beta Was this translation helpful? Give feedback.
It is unnecessary complexity, adding more corner cases for things to go wrong or to not be as polished for little gain. If you have a binary that is meant to be run outside of cargo, name it as such. If its a cargo plugin, then its that.