make sure Projects and Contexts are sorted
This commit is contained in:
parent
e8603bbc85
commit
96cc4ce27c
2
task.go
2
task.go
@ -53,12 +53,14 @@ func (task Task) String() string {
|
|||||||
text += task.Todo
|
text += task.Todo
|
||||||
|
|
||||||
if len(task.Contexts) > 0 {
|
if len(task.Contexts) > 0 {
|
||||||
|
sort.Strings(task.Contexts)
|
||||||
for _, context := range task.Contexts {
|
for _, context := range task.Contexts {
|
||||||
text += fmt.Sprintf(" @%s", context)
|
text += fmt.Sprintf(" @%s", context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(task.Projects) > 0 {
|
if len(task.Projects) > 0 {
|
||||||
|
sort.Strings(task.Projects)
|
||||||
for _, project := range task.Projects {
|
for _, project := range task.Projects {
|
||||||
text += fmt.Sprintf(" +%s", project)
|
text += fmt.Sprintf(" +%s", project)
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func (tasklist *TaskList) LoadFromFilename(filename string) error {
|
|||||||
|
|
||||||
// WriteToFilename writes a TaskList to the specified file (most likely called "todo.txt").
|
// WriteToFilename writes a TaskList to the specified file (most likely called "todo.txt").
|
||||||
func (tasklist *TaskList) WriteToFilename(filename string) error {
|
func (tasklist *TaskList) WriteToFilename(filename string) error {
|
||||||
return ioutil.WriteFile(filename, []byte(tasklist.String()), 0644)
|
return ioutil.WriteFile(filename, []byte(tasklist.String()), 0640)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFromFile loads and returns a TaskList from *os.File.
|
// LoadFromFile loads and returns a TaskList from *os.File.
|
||||||
|
Loading…
Reference in New Issue
Block a user