switch namespaces from tags to relations with auto-creation
This commit is contained in:
@@ -30,12 +30,9 @@ var createCmd = &cobra.Command{
|
||||
if slices.Contains(cTags, "_type::issue") && !slices.ContainsFunc(cTags, func(e string) bool { return strings.HasPrefix(e, "_status::") }) {
|
||||
cTags = append(cTags, "_status::open")
|
||||
}
|
||||
if !slices.ContainsFunc(cTags, func(e string) bool { return strings.HasPrefix(e, "_namespace::") }) {
|
||||
cTags = append(cTags, "_namespace::"+db.GetCurrentUser())
|
||||
}
|
||||
|
||||
rels := make(map[models.RelType][]string)
|
||||
relCreated := false
|
||||
relCreated, relNamespace := false, false
|
||||
for _, r := range cRels {
|
||||
rt, tgt, err := db.ParseRelFlag(r)
|
||||
if err != nil {
|
||||
@@ -45,11 +42,17 @@ var createCmd = &cobra.Command{
|
||||
if rt == models.RelCreated {
|
||||
relCreated = true
|
||||
}
|
||||
if rt == models.RelInNamespace {
|
||||
relNamespace = true
|
||||
}
|
||||
rels[rt] = append(rels[rt], tgt)
|
||||
}
|
||||
if !relCreated {
|
||||
rels[models.RelCreated] = append(rels[models.RelCreated], db.GetCurrentUser())
|
||||
}
|
||||
if !relNamespace {
|
||||
rels[models.RelInNamespace] = append(rels[models.RelInNamespace], db.GetCurrentUser())
|
||||
}
|
||||
|
||||
if n, err := d.CreateNode(db.CreateParams{Title: args[0], Content: cContent, DueDate: cDue, Tags: cTags, Rels: rels}); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "failed to create:", err)
|
||||
|
||||
Reference in New Issue
Block a user