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

Method run

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

Source from the content-addressed store, hash-verified

135 hey journal read 2026-03-15
136 hey journal read --html
137 hey journal read --json`,
138 RunE: journalReadCommand.run,
139 Args: cobra.MaximumNArgs(1),
140 }
141
142 return journalReadCommand
143}
144
145func (c *journalReadCommand) run(cmd *cobra.Command, args []string) error {
146 if err := requireAuth(); err != nil {
147 return err
148 }
149
150 date := time.Now().Format(dateLayout)
151 if len(args) > 0 {
152 if _, err := parseDateArg("date", args[0]); err != nil {
153 return err
154 }
155 date = args[0]
156 }
157
158 ctx := cmd.Context()
159 content, err := sdk.Journal().GetContent(ctx, date)
160 if err != nil {
161 return apierr.FromSDK(err)
162 }
163
164 // --html writes the entry's HTML and, for a day without one, nothing at all.
165 if writer.EffectiveFormat() == output.FormatHTML {
166 if content == "" {
167 return nil
168 }
169 _, err := fmt.Fprintln(cmd.OutOrStdout(), content)
170 return err
171 }
172
173 if content == "" {
174 if writer.IsStyled() {
175 fmt.Fprintf(cmd.OutOrStdout(), "Journal — %s\n\n(empty)\n", date)
176 return nil
177 }
178 return writeOK(nil, output.WithSummary(fmt.Sprintf("No journal entry for %s", date)))
179 }
180
181 if writer.IsStyled() {
182 w := cmd.OutOrStdout()
183 fmt.Fprintf(w, "Journal — %s\n\n", date)
184 fmt.Fprintln(w, markdown.Render(htmlutil.ToMarkdown(content), stdoutWidth()))

Callers

nothing calls this directly

Calls 7

WithSummaryFunction · 0.92
ToTextFunction · 0.92
WithBreadcrumbsFunction · 0.92
requireAuthFunction · 0.85
convertSDKErrorFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80

Tested by

no test coverage detected