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>
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>