Don't pass OutputFormat
to Context
anymore
#971
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.
It seems the only place where one of the commands actually uses the
OutputFormat
is currently here:cargo-msrv/src/sub_command/verify.rs
Line 76 in ab2870f
And from my testing it looks like this is redundant because if the output format is
NONE
, then the output handler will ignore all output anyway, so it does not matter whethererror_message
is passed along or not (but please verify yourself, if you want).This pull request is a proof of concept, showing that all the
OutputFormat
handling code can therefore be removed from theContext
code. This simplifies the code a bit, and also separates it more, because the context and command code probably does not care about theOutputFormat
;cargo-msrv.rs
handles all of that.What do you think?
The disadvantage is that if in the future for whatever reason the context or command code needs the output format again, it would have to be passed along again.
No problem if you don't think this change is useful. During my changes for #963 I was just curious whether it was possible to refactor the code in this way.