Brian McGee
c7d0138a02
Allows specifying the order in which formatters are applied. Very simple for now, adding a `Before` field to the formatted config which allows the user to say that formatter `x` needs to be applied _before_ formatted `y`. ```toml [formatter.statix] command = "statix" includes = ["*.nix"] before = "deadnix" [formatter.deadnix] command = "statix" includes = ["*.nix"] ``` Signed-off-by: Brian McGee <brian@bmcgee.ie> Reviewed-on: #20 Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com> Co-authored-by: Brian McGee <brian@bmcgee.ie> Co-committed-by: Brian McGee <brian@bmcgee.ie>
22 lines
675 B
Go
22 lines
675 B
Go
package format
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const (
|
|
completedChKey = "completedCh"
|
|
)
|
|
|
|
// SetCompletedChannel is used to set a channel for indication processing completion in the provided context.
|
|
func SetCompletedChannel(ctx context.Context, completedCh chan string) context.Context {
|
|
return context.WithValue(ctx, completedChKey, completedCh)
|
|
}
|
|
|
|
// MarkPathComplete is used to indicate that all processing has finished for the provided path.
|
|
// This is done by adding the path to the completion channel which should have already been set using
|
|
// SetCompletedChannel.
|
|
func MarkPathComplete(ctx context.Context, path string) {
|
|
ctx.Value(completedChKey).(chan string) <- path
|
|
}
|