MCPcopy
hub / github.com/mislav/hub / EditContent

Method EditContent

github/editor.go:75–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75func (e *Editor) EditContent() (content string, err error) {
76 b, err := e.openAndEdit()
77 if err != nil {
78 return
79 }
80
81 b = bytes.TrimSpace(b)
82 reader := bytes.NewReader(b)
83 scanner := bufio.NewScanner(reader)
84 unquotedLines := []string{}
85
86 scissorsLine := e.CS + " " + Scissors
87 for scanner.Scan() {
88 line := scanner.Text()
89 if line == scissorsLine {
90 break
91 }
92 unquotedLines = append(unquotedLines, line)
93 }
94 if err = scanner.Err(); err != nil {
95 return
96 }
97
98 content = strings.Join(unquotedLines, "\n")
99 return
100}
101
102func (e *Editor) openAndEdit() (content []byte, err error) {
103 err = e.writeContent()

Callers 1

ExtractMethod · 0.80

Calls 1

openAndEditMethod · 0.95

Tested by

no test coverage detected