accept just a string for a todo task that converts to a struct on parse

This commit is contained in:
Bel LaPointe
2021-12-31 16:39:54 -05:00
parent c1ed21ce19
commit ce7bd17e72
3 changed files with 57 additions and 0 deletions

View File

@@ -15,3 +15,13 @@ func (todo Todo) Triggered() bool {
next, err := todo.Schedule.Next(last.time())
return err == nil && time.Now().After(next)
}
func (todo *Todo) UnmarshalYAML(unmarshal func(interface{}) error) error {
*todo = Todo{}
if err := unmarshal(&todo.Todo); err == nil {
return nil
}
type Alt Todo
alt := (*Alt)(todo)
return unmarshal(alt)
}