()
| 184 | } |
| 185 | |
| 186 | func (m model) Init() tea.Cmd { |
| 187 | cmds := []tea.Cmd{m.stash.spinner.Tick} |
| 188 | |
| 189 | switch m.state { |
| 190 | case stateShowStash: |
| 191 | cmds = append(cmds, findLocalFiles(*m.common)) |
| 192 | case stateShowDocument: |
| 193 | content, err := os.ReadFile(m.common.cfg.Path) |
| 194 | if err != nil { |
| 195 | log.Error("unable to read file", "file", m.common.cfg.Path, "error", err) |
| 196 | return func() tea.Msg { return errMsg{err} } |
| 197 | } |
| 198 | body := string(utils.RemoveFrontmatter(content)) |
| 199 | cmds = append(cmds, renderWithGlamour(m.pager, body)) |
| 200 | } |
| 201 | |
| 202 | return tea.Batch(cmds...) |
| 203 | } |
| 204 | |
| 205 | func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 206 | // If there's been an error, any key exits |
no test coverage detected