Files
terraform-docs/internal/module/options.go
Khosrow Moossavi 38e18970ed refactor: Introduce Format interface and expose to public pkg (#195)
* Introduce format interface and expose to public pkg

* fix issues after merge

* don't panic

* Rename TFString back to String
2020-02-19 14:07:10 -05:00

41 lines
827 B
Go

package module
import (
"log"
"github.com/imdario/mergo"
)
// SortBy contains different sort criteria corresponding
// to available flags (e.g. name, required, etc)
type SortBy struct {
Name bool
Required bool
}
// Options contains required options to load a Module from path
type Options struct {
Path string
SortBy *SortBy
OutputValues bool
OutputValuesPath string
}
// NewOptions returns new instance of Options
func NewOptions() *Options {
return &Options{
Path: "",
SortBy: &SortBy{Name: false, Required: false},
OutputValues: false,
OutputValuesPath: "",
}
}
// With override options with existing Options
func (o *Options) With(override *Options) *Options {
if err := mergo.Merge(o, override); err != nil {
log.Fatal(err)
}
return o
}