feat: add run result

This commit is contained in:
2025-10-14 22:23:06 +03:00
parent fe9568d7ae
commit b3844fa226
5 changed files with 118 additions and 33 deletions

23
chain_processor.go Normal file
View File

@@ -0,0 +1,23 @@
package script
import "context"
// Chain chains provided Processors.
// When an error is returned by a Processor in chain, processing
// stops and the error is retuned without running further stages.
func Chain(processors ...Processor) Processor {
return func(ctx context.Context, in []string) ([]string, error) {
var err error
for _, p := range processors {
// not checking ctx expiry here,
// let the processor handle it
in, err = p(ctx, in)
if err != nil {
return nil, err
}
}
return in, nil
}
}