forked from dotnet/format
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read --{in,ex}clude values from stdin
Today, `dotnet-format` accepts space-separated list of files. This allows us to pass files via shell's native globbing expansion, heredoc style redirections as well as via pipelines (see dotnet#551 for examples). However, in case of pipeline it requires a second utility (`xarg`) to transform pipeline input as space-separated list to `dotnet-format`. This PR implements native pipeline reading support for `--include` and `--exclude` options, while keeping the space-separated list intact. Usage examples: 1. Include all C# source files under `tests/Utilities` directory that are in git source tree: ```sh git ls-files :/tests/Utilities/*.cs | dotnet format --include - --folder ``` 2. Exclude certain `*.cs` and `*.vb` files using `ls(1)`: ```sh ls ../../../../../src/generated/{*.cs,*.vb} | dotnet format --exclude /dev/stdin --folder ``` Rules: * Based on Guideline 13 of [IEEE 1003.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02) (POSIX), it accepts `-` as an explicit marker for stdin with addition of: * `/dev/stdin` - which is a universal synonym of `-` on all Unices. * It *only* accepts explicit markers (`/dev/stdin` or `-`) and does not implicit deduce the output if standard input was redirected, but marker was not present. This is because our usage is multi-purpose (both `--include` and `--exclude`). * It is an error if both `--include` and `--exclude` are using stdin marker (`/dev/stdin` or `-`). Limitation: * Currently, it reads the entire input from pipeline in `include`/`exclude` buffer, and then runs the operation on the whole batch. In order to make the pipele , it would require some refactorings; so files `yield return` and enumerator dispatches format operation per file. * At present, we do not have out-of-process functional tests for CLI to effectively validate these kind of use-cases (redirection and shell globbing vs. dotnet-format's built-in globbing support); so PR did not included any new mechanism.
- Loading branch information
Showing
16 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters