(cmd *cobra.Command, args []string)
| 33 | EmailAddress string `json:"email_address"` |
| 34 | } |
| 35 | |
| 36 | // threadEntry is one message in a thread. Body is Markdown, converted once here from |
| 37 | // HEY's Trix HTML; BodyHTML keeps that HTML for --html. |
| 38 | type threadEntry struct { |
| 39 | ID int64 `json:"id"` |
| 40 | CreatedAt string `json:"created_at"` |
| 41 | UpdatedAt string `json:"updated_at"` |
| 42 | Creator threadContact `json:"creator"` |
| 43 | AlternativeSenderName string `json:"alternative_sender_name"` |
| 44 | Summary string `json:"summary"` |
| 45 | Kind string `json:"kind"` |
| 46 | AppURL string `json:"app_url"` |
| 47 | Body string `json:"body,omitempty"` |
| 48 | BodyHTML string `json:"-"` |
| 49 | } |
| 50 | |
| 51 | type topicCommand struct { |
| 52 | cmd *cobra.Command |
| 53 | } |
| 54 | |
| 55 | func newThreadsCommand() *topicCommand { |
| 56 | threadsCommand := &topicCommand{} |
| 57 | threadsCommand.cmd = &cobra.Command{ |
| 58 | Use: "threads <id>", |
| 59 | Short: "Read a thread", |
| 60 | Annotations: map[string]string{ |
| 61 | "agent_notes": "Returns a thread with all entries, oldest first. Entry bodies are Markdown; --html returns HEY's original HTML instead. Use the topic ID with hey reply or hey forward.", |
| 62 | }, |
| 63 | Example: ` hey threads 12345 |
| 64 | hey threads 12345 --json`, |
| 65 | RunE: threadsCommand.run, |
| 66 | Args: usageExactOneArg(), |
| 67 | } |
| 68 | |
| 69 | return threadsCommand |
| 70 | } |
| 71 | |
| 72 | func (c *topicCommand) run(cmd *cobra.Command, args []string) error { |
| 73 | if err := requireAuth(); err != nil { |
| 74 | return err |
| 75 | } |
| 76 | |
| 77 | threadID, err := strconv.ParseInt(args[0], 10, 64) |
| 78 | if err != nil { |
| 79 | return apierr.ErrUsage(fmt.Sprintf("invalid thread ID: %s", args[0])) |
| 80 | } |
| 81 | |
| 82 | entries, err := entriesInThread(cmd.Context(), threadID) |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | if writer.IsStyled() { |
| 88 | w := cmd.OutOrStdout() |
| 89 | for i, e := range entries { |
| 90 | if i > 0 { |
| 91 | fmt.Fprintln(w, strings.Repeat("─", threadEntrySeparatorWidth)) |
| 92 | } |
nothing calls this directly
no test coverage detected