MCPcopy Create free account
hub / github.com/basecamp/hey-cli / run

Method run

internal/cmd/journal.go:60–113  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

58}
59
60func (c *journalListCommand) run(cmd *cobra.Command, args []string) error {
61 if err := requireAuth(); err != nil {
62 return err
63 }
64
65 ctx := cmd.Context()
66 resp, err := listPersonalRecordings(ctx)
67 if err != nil {
68 return err
69 }
70
71 entries := filterRecordingsByType(resp, "Calendar::JournalEntry")
72
73 total := len(entries)
74 if c.limit > 0 && !c.all && len(entries) > c.limit {
75 entries = entries[:c.limit]
76 }
77 notice := output.TruncationNotice(len(entries), total)
78
79 if writer.IsStyled() {
80 if len(entries) == 0 {
81 fmt.Fprintln(cmd.OutOrStdout(), "No journal entries.")
82 return nil
83 }
84
85 table := newTable(cmd.OutOrStdout())
86 table.addRow([]string{"ID", "Date", "Preview"})
87 for _, e := range entries {
88 table.addRow([]string{fmt.Sprintf("%d", e.Id), formatDate(e.StartsAt), truncate(e.Content, 60)})
89 }
90 table.print()
91 if notice != "" {
92 fmt.Fprintln(cmd.OutOrStdout(), notice)
93 }
94 return nil
95 }
96
97 return writeOK(entries,
98 output.WithSummary(fmt.Sprintf("%d journal entries", len(entries))),
99 output.WithNotice(notice),
100 output.WithBreadcrumbs(
101 output.Breadcrumb{
102 Action: "read",
103 Command: "hey journal read [date]",
104 Description: "Read a journal entry",
105 },
106 output.Breadcrumb{
107 Action: "write",
108 Command: "hey journal write '...'",
109 Description: "Write a journal entry",
110 },
111 ),
112 )
113}
114
115// read
116

Callers

nothing calls this directly

Calls 14

TruncationNoticeFunction · 0.92
WithSummaryFunction · 0.92
WithNoticeFunction · 0.92
WithBreadcrumbsFunction · 0.92
requireAuthFunction · 0.85
listPersonalRecordingsFunction · 0.85
filterRecordingsByTypeFunction · 0.85
newTableFunction · 0.85
formatDateFunction · 0.85
truncateFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80

Tested by

no test coverage detected