ref: d19400c6e709f42f685c96c62426213fae4d91ec
parent: c729b5b0b2c42c5b9ac04a312ab6deb7af54805c
author: Michael Misch <michaelmisch1985@gmail.com>
date: Wed Nov 27 16:27:19 PST 2019
Add ability to create entry in .todo
--- a/task.go
+++ b/task.go
@@ -102,6 +102,9 @@
}
switch c.args[0] {
+ case "create":
+ defer l.write()
+ return l.create(c.args[1])
case "add":
if l.exists(c.args[1], c.args[2]) {
return fmt.Errorf("Entry exists")
@@ -124,6 +127,17 @@
default:
return fmt.Errorf("Command not supported: %v", c.args[0])
}
+}
+
+func (l *layout) create(title string) error {
+ if len(title) < 1 {
+ return errors.New("Unable to add nil entry")
+ }
+ l.TaskList = append(l.TaskList, &entries{
+ Title: title,
+ List: []*entry{},
+ })
+ return nil
}
func (l *layout) write() {