MCPcopy Create free account
hub / github.com/driangle/taskmd / removeProjectNode

Function removeProjectNode

apps/cli/internal/cli/project_registry.go:304–320  ·  view source on GitHub ↗

removeProjectNode removes a project entry matching key=val from the projects sequence. Returns the removed project's ID and true, or "" and false if not found.

(doc *yaml.Node, key, val string)

Source from the content-addressed store, hash-verified

302// removeProjectNode removes a project entry matching key=val from the projects sequence.
303// Returns the removed project's ID and true, or "" and false if not found.
304func removeProjectNode(doc *yaml.Node, key, val string) (string, bool) {
305 if len(doc.Content) == 0 {
306 return "", false
307 }
308 seq := findProjectsSequence(doc.Content[0])
309 if seq == nil || seq.Kind != yaml.SequenceNode {
310 return "", false
311 }
312 for i, item := range seq.Content {
313 entry := nodeToProjectEntry(item)
314 if matchesEntry(entry, key, val) {
315 seq.Content = append(seq.Content[:i], seq.Content[i+1:]...)
316 return entry.ID, true
317 }
318 }
319 return "", false
320}
321
322func matchesEntry(entry GlobalProjectEntry, key, val string) bool {
323 switch key {

Callers 1

runProjectUnregisterFunction · 0.85

Calls 3

findProjectsSequenceFunction · 0.85
nodeToProjectEntryFunction · 0.85
matchesEntryFunction · 0.85

Tested by

no test coverage detected