databricks-cli/cmd/internal/test.go

22 lines
380 B
Go

package internal
import (
"bytes"
"context"
"github.com/databricks/cli/cmd"
)
func RunGetOutput(ctx context.Context, args ...string) ([]byte, error) {
root := cmd.New()
args = append(args, "--log-level", "debug")
root.SetArgs(args)
var buf bytes.Buffer
root.SetOut(&buf)
err := root.ExecuteContext(ctx)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}