github.com/wtfutil/wtf@v0.43.0/modules/asana/settings.go (about) 1 package asana 2 3 import ( 4 "github.com/olebedev/config" 5 "github.com/wtfutil/wtf/cfg" 6 "github.com/wtfutil/wtf/utils" 7 ) 8 9 const ( 10 defaultFocusable = true 11 defaultTitle = "Asana" 12 ) 13 14 type Settings struct { 15 *cfg.Common 16 17 projectId string `help:"The Asana Project ID. If the mode is 'project' or 'project_sections' this is required to known which Asana Project to pull your tasks from" values:"A valid Asana Project ID string" optional:"true"` 18 19 workspaceId string `help:"The Asana Workspace ID. If mode is 'workspace' this is required" values:"A valid Asana Workspace ID string" optional:"true"` 20 21 sections []string `help:"The Asana Section Labels to fetch from the Project. Required if the mode is 'project_sections'" values:"An array of Asana Section Label strings" optional:"true"` 22 23 allUsers bool `help:"Fetch tasks for all users, defaults to false" values:"bool" optional:"true"` 24 25 mode string `help:"What mode to query Asana, 'project', 'project_sections', 'workspace'" values:"A string with either 'project', 'project_sections' or 'workspace'"` 26 27 hideComplete bool `help:"Hide completed tasks, defaults to false" values:"bool" optional:"true"` 28 29 apiKey string `help:"Your Asana Personal Access Token. Leave this blank to use the WTF_ASANA_TOKEN environment variable." values:"Your Asana Personal Access Token as a string" optional:"true"` 30 31 token string 32 } 33 34 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 35 settings := Settings{ 36 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, 37 globalConfig), 38 projectId: ymlConfig.UString("projectId", ""), 39 apiKey: ymlConfig.UString("apiKey", ""), 40 workspaceId: ymlConfig.UString("workspaceId", ""), 41 sections: utils.ToStrs(ymlConfig.UList("sections")), 42 allUsers: ymlConfig.UBool("allUsers", false), 43 mode: ymlConfig.UString("mode", ""), 44 hideComplete: ymlConfig.UBool("hideComplete", false), 45 } 46 47 return &settings 48 }