MCPcopy
hub / github.com/charmbracelet/glow / Init

Method Init

ui/ui.go:186–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184}
185
186func (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
205func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
206 // If there's been an error, any key exits

Callers 1

UpdateMethod · 0.95

Calls 4

RemoveFrontmatterFunction · 0.92
findLocalFilesFunction · 0.85
renderWithGlamourFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected