MCPcopy
hub / github.com/kopia/kopia / run

Method run

cli/command_notification_template_show.go:38–73  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

36}
37
38func (c *commandNotificationTemplateShow) run(ctx context.Context, rep repo.Repository) error {
39 var (
40 text string
41 err error
42 )
43
44 if c.original {
45 text, err = notifytemplate.GetEmbeddedTemplate(c.templateName)
46 } else {
47 var found bool
48
49 text, found, err = notifytemplate.GetTemplate(ctx, rep, c.templateName)
50 if !found {
51 text, err = notifytemplate.GetEmbeddedTemplate(c.templateName)
52 }
53 }
54
55 if err != nil {
56 return errors.Wrap(err, "error listing templates")
57 }
58
59 if c.htmlOutput {
60 tf := filepath.Join(os.TempDir(), "kopia-template-preview.html")
61
62 //nolint:gosec,mnd
63 if err := os.WriteFile(tf, []byte(text), 0o644); err != nil {
64 return errors.Wrap(err, "error writing template to file")
65 }
66
67 open.Run(tf) //nolint:errcheck
68 }
69
70 c.out.printStdout("%v\n", strings.TrimRight(text, "\n"))
71
72 return nil
73}

Callers

nothing calls this directly

Calls 5

GetEmbeddedTemplateFunction · 0.92
GetTemplateFunction · 0.92
printStdoutMethod · 0.80
WriteFileMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected