MCPcopy Index your code
hub / github.com/coder/coder / customNotifications

Method customNotifications

cli/notifications.go:126–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126func (r *RootCmd) customNotifications() *serpent.Command {
127 cmd := &serpent.Command{
128 Use: "custom <title> <message>",
129 Short: "Send a custom notification",
130 Middleware: serpent.Chain(
131 serpent.RequireNArgs(2),
132 ),
133 Handler: func(inv *serpent.Invocation) error {
134 client, err := r.InitClient(inv)
135 if err != nil {
136 return err
137 }
138 err = client.PostCustomNotification(inv.Context(), codersdk.CustomNotificationRequest{
139 Content: &codersdk.CustomNotificationContent{
140 Title: inv.Args[0],
141 Message: inv.Args[1],
142 },
143 })
144 if err != nil {
145 return xerrors.Errorf("unable to post custom notification: %w", err)
146 }
147
148 _, _ = fmt.Fprintln(inv.Stderr, "A custom notification has been sent.")
149 return nil
150 },
151 }
152 return cmd
153}

Callers 1

notificationsMethod · 0.95

Calls 4

InitClientMethod · 0.95
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected