Add ignore flag to be used with workspace option
Sometimes it can be useful to exclude certain modules/Cargo.toml files when running cargo sort on a complete workspace. For example if you use a workspace-hack module.
This pull requests adds a ignore flag (-i/--ignore) that can be used in combination with the workspace flag ( -w/ --workspace) that lets a user specify modules that should be skipped when running cargo sort. Example usage:
cargo sort -w -i "workspace-hack" my_project
The ignore flag also supports a list of values and the ? and * glob patterns:
cargo sort -w -i "workspace-hack","ignore*" my_project
I am not opposed to adding this although I do wonder why you want to skip it. There isn't any harm in sorting that file too, is there? What is the motivation as to why it should be skipped?
The original idea/problem as to why I opened this pull request was the following. We have a CI pipeline that uses hakari to speed up builds. The idea now is to add cargo sort to that. However (our) hakari expects a very specific order for the workspace-hack module. Not doing anything would result in the two passing the workspace-hack/Cargo.toml between each other and both sorting the same file differently.
So as you mentioned one option would be to define an explicit order that sorts all Cargo.tomls in such a way that everyone is happy, but then do not necessarily want one auto-generated module to dictate how every other Toml should be sorted (which would be 80+ in our case). By skipping the workspace-hack one we could keep the others that people in my Team actually use, in the format/order that we would prefer and just leave the one auto generated one out.
Thank you for explaining your usecase. That makes sense to me, tools fighting each other is no fun :)
I'll give this a review in the upcoming days.