MCPcopy Index your code
hub / github.com/larksuite/cli / readMarkdownLocalFile

Function readMarkdownLocalFile

shortcuts/markdown/markdown_diff.go:183–198  ·  view source on GitHub ↗
(runtime *common.RuntimeContext, filePath string)

Source from the content-addressed store, hash-verified

181}
182
183func readMarkdownLocalFile(runtime *common.RuntimeContext, filePath string) (string, error) {
184 f, err := runtime.FileIO().Open(filePath)
185 if err != nil {
186 return "", withMarkdownFileParam(common.WrapInputStatErrorTyped(err), "--file")
187 }
188 defer f.Close()
189
190 payload, err := readMarkdownDiffPayload(f, "local Markdown file")
191 if err != nil {
192 if _, ok := errs.ProblemOf(err); ok {
193 return "", withMarkdownFileParam(err, "--file")
194 }
195 return "", markdownValidationParamError("--file", "cannot read file: %s", err).WithCause(err)
196 }
197 return string(payload), nil
198}
199
200func readMarkdownDiffPayload(r io.Reader, source string) ([]byte, error) {
201 payload, err := io.ReadAll(io.LimitReader(r, markdownDiffMaxContentBytes+1))

Callers 1

markdown_diff.goFile · 0.85

Calls 9

WrapInputStatErrorTypedFunction · 0.92
ProblemOfFunction · 0.92
withMarkdownFileParamFunction · 0.85
readMarkdownDiffPayloadFunction · 0.85
FileIOMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.45
WithCauseMethod · 0.45

Tested by

no test coverage detected