github.com/wtfutil/wtf@v0.43.0/modules/gitlabtodo/settings.go (about) 1 package gitlabtodo 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 ) 9 10 const ( 11 defaultFocusable = true 12 defaultTitle = "GitLab Todos" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 numberOfTodos int `help:"Defines number of stories to be displayed. Default is 10" optional:"true"` 19 apiKey string `help:"A GitLab personal access token. Requires at least api access."` 20 domain string `help:"Your GitLab corporate domain."` 21 showProject bool `help:"Determines whether or not to show the project a given todo is for."` 22 } 23 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 numberOfTodos: ymlConfig.UInt("numberOfTodos", 10), 30 apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_GITLAB_TOKEN")), 31 domain: ymlConfig.UString("domain", "https://gitlab.com"), 32 showProject: ymlConfig.UBool("showProject", true), 33 } 34 35 cfg.ModuleSecret(name, globalConfig, &settings.apiKey). 36 Service(settings.domain).Load() 37 38 return &settings 39 }