forked from kopia/kopia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_notification_template.go
More file actions
45 lines (34 loc) · 1.16 KB
/
Copy pathcommand_notification_template.go
File metadata and controls
45 lines (34 loc) · 1.16 KB
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
43
44
45
package cli
import (
"context"
"github.com/alecthomas/kingpin/v2"
"github.com/kopia/kopia/notification/notifytemplate"
"github.com/kopia/kopia/repo"
)
type commandNotificationTemplate struct {
list commandNotificationTemplateList
show commandNotificationTemplateShow
set commandNotificationTemplateSet
remove commandNotificationTemplateRemove
}
type notificationTemplateNameArg struct {
templateName string
}
func (c *notificationTemplateNameArg) setup(svc appServices, cmd *kingpin.CmdClause) {
cmd.Arg("template", "Template name").Required().HintAction(svc.repositoryHintAction(c.listNotificationTemplates)).StringVar(&c.templateName)
}
func (c *notificationTemplateNameArg) listNotificationTemplates(ctx context.Context, rep repo.Repository) []string {
infos, _ := notifytemplate.ListTemplates(ctx, rep, c.templateName)
var hints []string
for _, ti := range infos {
hints = append(hints, ti.Name)
}
return hints
}
func (c *commandNotificationTemplate) setup(svc appServices, parent commandParent) {
cmd := parent.Command("template", "Manage templates")
c.list.setup(svc, cmd)
c.set.setup(svc, cmd)
c.show.setup(svc, cmd)
c.remove.setup(svc, cmd)
}