(ctx context.Context, flags *RootFlags, keep *KeepCmd)
| 197 | } |
| 198 | |
| 199 | func (c *KeepGetCmd) Run(ctx context.Context, flags *RootFlags, keep *KeepCmd) error { |
| 200 | u := ui.FromContext(ctx) |
| 201 | |
| 202 | svc, err := getKeepService(ctx, flags, keep) |
| 203 | if err != nil { |
| 204 | return err |
| 205 | } |
| 206 | |
| 207 | name := c.NoteID |
| 208 | if !strings.HasPrefix(name, "notes/") { |
| 209 | name = "notes/" + name |
| 210 | } |
| 211 | |
| 212 | note, err := svc.Notes.Get(name).Do() |
| 213 | if err != nil { |
| 214 | return err |
| 215 | } |
| 216 | |
| 217 | if outfmt.IsJSON(ctx) { |
| 218 | return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{"note": note}) |
| 219 | } |
| 220 | |
| 221 | u.Out().Linef("name\t%s", note.Name) |
| 222 | u.Out().Linef("title\t%s", note.Title) |
| 223 | u.Out().Linef("created\t%s", note.CreateTime) |
| 224 | u.Out().Linef("updated\t%s", note.UpdateTime) |
| 225 | u.Out().Linef("trashed\t%v", note.Trashed) |
| 226 | if note.Body != nil && note.Body.Text != nil { |
| 227 | u.Out().Println("") |
| 228 | u.Out().Println(note.Body.Text.Text) |
| 229 | } |
| 230 | if len(note.Attachments) > 0 { |
| 231 | u.Out().Println("") |
| 232 | u.Out().Linef("attachments\t%d", len(note.Attachments)) |
| 233 | for _, a := range note.Attachments { |
| 234 | u.Out().Linef(" %s\t%s", a.Name, a.MimeType) |
| 235 | } |
| 236 | } |
| 237 | return nil |
| 238 | } |
| 239 | |
| 240 | type KeepAttachmentCmd struct { |
| 241 | AttachmentName string `arg:"" name:"attachmentName" help:"Attachment name (e.g. notes/abc123/attachments/xyz789)"` |
nothing calls this directly
no test coverage detected