Files
opentf/internal/command/views/fmt.go

39 lines
829 B
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package views
import (
"io"
"github.com/opentofu/opentofu/internal/tfdiags"
)
type Fmt interface {
Diagnostics(diags tfdiags.Diagnostics)
UserOutputWriter() io.Writer
}
// NewFmt returns an initialized Fmt implementation.
func NewFmt(view *View) Fmt {
return &FmtHuman{view: view}
}
type FmtHuman struct {
view *View
}
var _ Fmt = (*FmtHuman)(nil)
func (v *FmtHuman) Diagnostics(diags tfdiags.Diagnostics) {
v.view.Diagnostics(diags)
}
// UserOutputWriter returns a [io.Writer] that uses the [FmtHuman.view] as a proxy to write
// the user facing information during formatting.
func (v *FmtHuman) UserOutputWriter() io.Writer {
return v.view.streams.Stdout.File
}