github.com/wtfutil/wtf@v0.43.0/modules/textfile/settings.go (about)

     1  package textfile
     2  
     3  import (
     4  	"github.com/olebedev/config"
     5  	"github.com/wtfutil/wtf/cfg"
     6  )
     7  
     8  const (
     9  	defaultFocusable = true
    10  	defaultTitle     = "Textfile"
    11  )
    12  
    13  // Settings defines the configuration properties for this module
    14  type Settings struct {
    15  	*cfg.Common
    16  
    17  	filePaths   []interface{}
    18  	format      bool
    19  	formatStyle string
    20  	wrapText    bool
    21  }
    22  
    23  // NewSettingsFromYAML creates a new settings instance from a YAML config block
    24  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    25  
    26  	settings := Settings{
    27  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    28  
    29  		filePaths:   ymlConfig.UList("filePaths"),
    30  		format:      ymlConfig.UBool("format", false),
    31  		formatStyle: ymlConfig.UString("formatStyle", "vim"),
    32  		wrapText:    ymlConfig.UBool("wrapText", true),
    33  	}
    34  
    35  	return &settings
    36  }