From f699fdc219fc40d88ee387fbccdb9a0cf80f1697 Mon Sep 17 00:00:00 2001 From: peefy Date: Mon, 5 Aug 2024 11:31:01 +0800 Subject: [PATCH] feat: add WithLogger option for kpm v0.9.x Signed-off-by: peefy --- pkg/client/run.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/client/run.go b/pkg/client/run.go index 653bd28a..dcddbd44 100644 --- a/pkg/client/run.go +++ b/pkg/client/run.go @@ -65,6 +65,7 @@ package client import ( "errors" "fmt" + "io" "os" "path/filepath" @@ -88,6 +89,16 @@ type RunOptions struct { type RunOption func(*RunOptions) error +func WithLogger(l io.Writer) RunOption { + return func(ro *RunOptions) error { + if ro.Option == nil { + ro.Option = kcl.NewOption() + } + ro.Merge(kcl.WithLogger(l)) + return nil + } +} + // WithWorkDir sets the work directory for running the kcl package. func WithWorkDir(workDir string) RunOption { return func(ro *RunOptions) error {