fix cargo-mutagen usage as cargo subcommand #165
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cargo passes all args to the subcommand program, which means our binary will receive "mutagen" as first argument when invoked like this:
This produced an error, because structopt doesn't expect a "mutagen" argument at all:
For a similar problem, see rust-lang/rustfmt#3569.
This is how they handle it: https://github.com/rust-lang/rustfmt/blob/9124dd88d6ef14d0ae77dc52ff5e9598f24a75a0/rustfmt-core/rustfmt-bin/src/cargo-fmt/main.rs#L77
I've opted for a simpler solution because I don't think
mutagencould be one of the arguments forcargo-mutagencurrently (naming an eventual featuremutagendoesn't seem right). If you think this might be a problem later on, we can find a better fix :)