/
customapps.go
42 lines (32 loc) · 900 Bytes
/
customapps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package customapps
import (
"strings"
"github.com/toboshii/hajimari/internal/config"
"github.com/toboshii/hajimari/internal/models"
)
// List struct is used for listing hajimari apps
type List struct {
appConfig config.Config
err error // Used for forwarding errors
items []models.AppGroup
}
// NewList func creates a new instance of apps lister
func NewList(appConfig config.Config) *List {
return &List{
appConfig: appConfig,
}
}
// Populate function that populates a list of custom apps
func (al *List) Populate() *List {
var customApps []models.AppGroup
for _, group := range al.appConfig.CustomApps {
group.Group = strings.ToLower(group.Group)
customApps = append(customApps, group)
}
al.items = customApps
return al
}
// Get function returns the apps currently present in List
func (al *List) Get() ([]models.AppGroup, error) {
return al.items, al.err
}