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

     1  package transmission
     2  
     3  import (
     4  	"github.com/olebedev/config"
     5  	"github.com/wtfutil/wtf/cfg"
     6  )
     7  
     8  const (
     9  	defaultFocusable = true
    10  	defaultTitle     = "Transmission"
    11  )
    12  
    13  // Settings defines the configuration properties for this module
    14  type Settings struct {
    15  	*cfg.Common
    16  
    17  	host         string `help:"The address of the machine the Transmission daemon is running on"`
    18  	https        bool   `help:"Whether or not to connect to the host via HTTPS"`
    19  	password     string `help:"The password for the Transmission user"`
    20  	port         uint16 `help:"The port to connect to the Transmission daemon on"`
    21  	url          string `help:"The RPC URI that the daemon is accessible at"`
    22  	username     string `help:"The username of the Transmission user"`
    23  	hideComplete bool   `help:"Hide the torrents that are finished downloading"`
    24  }
    25  
    26  // NewSettingsFromYAML creates a new settings instance from a YAML config block
    27  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    28  	settings := Settings{
    29  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    30  
    31  		host:         ymlConfig.UString("host"),
    32  		https:        ymlConfig.UBool("https", false),
    33  		password:     ymlConfig.UString("password"),
    34  		port:         uint16(ymlConfig.UInt("port", 9091)),
    35  		url:          ymlConfig.UString("url", ""),
    36  		username:     ymlConfig.UString("username", ""),
    37  		hideComplete: ymlConfig.UBool("hideComplete", false),
    38  	}
    39  
    40  	return &settings
    41  }