Separates global excludes processing from `Formatter.Wants`. This removes redundant processing of global excludes in each `Formatter.Wants` call.
If a file has been globally excluded, we do not emit an `on-unmatched` log message. This should help reduce as reported in #317.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
This was incorrectly ported from Rust to Go.
When `--stdin` is provided, `treefmt` copy the `stdin` into a temporary file, using the first path argument as the filename. This allows the user to control which formatters will match this temp file based on their `treefmt` config.
After the formatters have been applied, the contents of this temporary file are then printed to stdout and the temp file is removed.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
This was incorrectly ported from Rust to Go.
When provided, `treefmt` will take the contents of stdin and place them into the file provided with the `--stdin` flag, then format it according to the configured formatters.
If the file doesn't exist it is created. If it exists, it is first truncated and then populated with stdin.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
For each path we determine the list of formatters that are interested in formatting it. From there, we sort
the list of formatters first by priority (lower value, higher priority) and then by name (lexicographically).
With this information we create a batch key which is based on the unique sequence of formatters. When enough paths with the same sequence is ready we apply them in order to each formatter.
By default, with no special configuration, this model guarantees that a given path will only be processed by one formatter at a time.
If a user wishes to influence the order in which formatters are applied they can use the priority field.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Replaces the `Before` config option with an optional `Pipeline` key.
This is used to group formatters together in the order in which they are specified within the config file.
Signed-off-by: Brian McGee <brian@bmcgee.ie>