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>
Restore the treefmt 1.x behaviour where it would search for the tree
root by recursively searching for the treefmt.toml file up the
filesystem, starting from the current directory.
The `--tree-root-file` option will be useful to remove this bash wrapper: 2fba33a182/module-options.nix (L116-L135)Fixes#308
By default, if a path does not match any formatter a log message at WARN level will be emitted. A user can change this by providing the `--on-unmatched` or `-u` flag and specifying a log level `debug,info,warn,error,fatal`.
If fatal, the process will exit with an error on the first unmatched path encountered.
Closes#302
Signed-off-by: Brian McGee <brian@bmcgee.ie>
We currently publish an update when we merge to `main`. This means new functionality that is not yet released is being talked about on the docs site.
This restricts deploying to github pages to only published releases.
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>