Files
kopia/cli/command_notification_configure_testsender.go
Jarek Kowalski c0bd372d29 feat(cli): support for defining notification profiles and templates via CLI (#4034)
* feat(cli): support for defining notification profiles via CLI

Profile management:

```
$ kopia notification profile configure email \
    --profile-name=X \
    --smtp-server=smtp.gmail.com \
    --smtp-port=587 \
    --smtp-username=X \
    --smtp-password=X \
    --mail-from=X \
    --mail-to=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure pushover --profile-name=X \
    --user-key=X \
    --app-token=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure webhook --profile-name=X \
    --endpooint=http://some-address:port/path \
    --method=POST|PUT \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile test --profile-name=X

$ kopia notification profile delete --profile-name=X

$ kopia notification profile list
```

Template management:

```
$ kopia notification template show X

$ kopia notification template set X \
   --from-stdin | --from-file=X | --editor

$ kopia notification template remove X

$ kopia notification template list

```

Implements #1958

* additional refactoring for testability, various naming tweaks
2024-10-06 16:28:39 +00:00

22 lines
657 B
Go

package cli
import (
"github.com/kopia/kopia/notification/sender"
"github.com/kopia/kopia/notification/sender/testsender"
)
type commandNotificationConfigureTestSender struct {
common commonNotificationOptions
opt testsender.Options
}
func (c *commandNotificationConfigureTestSender) setup(svc appServices, parent commandParent) {
cmd := parent.Command("testsender", "Testing notification.")
c.common.setup(svc, cmd)
cmd.Flag("format", "Format of the message").EnumVar(&c.opt.Format, sender.FormatHTML, sender.FormatPlainText)
cmd.Action(configureNotificationAction(svc, &c.common, testsender.ProviderType, &c.opt, testsender.MergeOptions))
}