add anti tag search

Bel LaPointe 2022-01-04 07:01:35 -05:00
parent 64868bdc0b
commit cf3b233a11
2 changed files with 9 additions and 3 deletions

View File

@ -38,7 +38,7 @@ func _main() error {
filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file") filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file")
filepathToMergeIn := flag.String("g", "", "path to yaml file to merge into -f") filepathToMergeIn := flag.String("g", "", "path to yaml file to merge into -f")
root := flag.String("root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")") root := flag.String("root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")")
tags := flag.String("tags", "", "csv of all tags to find") tags := flag.String("tags", "", "csv of all tags to find, -tag to invert")
search := flag.String("search", "", "fts case insensitive") search := flag.String("search", "", "fts case insensitive")
e := flag.Bool("e", false, "edit file") e := flag.Bool("e", false, "edit file")
dry := flag.Bool("dry", false, "dry run") dry := flag.Bool("dry", false, "dry run")
@ -257,7 +257,10 @@ func dump(dry bool, writer io.Writer, filepath string, tags []string, search, ro
for _, todo := range todos { for _, todo := range todos {
want := len(todo.Tags) > 0 want := len(todo.Tags) > 0
for _, tag := range tags { for _, tag := range tags {
want = want && strings.Contains(todo.Tags, tag) positiveTag := strings.TrimLeft(tag, "-")
hasTag := strings.Contains(todo.Tags, positiveTag)
wantToHaveTag := !strings.HasPrefix(tag, "-")
want = want && (hasTag == wantToHaveTag)
} }
if want { if want {
result = append(result, todo) result = append(result, todo)

View File

@ -1,4 +1,6 @@
todo: todo:
- when merging, check for complete/incomplete and cross reference todo vs scheduled
vs done
- how to defer a scheduled task? - how to defer a scheduled task?
- merge multi todo files for 'inbox' style with some dedupe (probably best to just - merge multi todo files for 'inbox' style with some dedupe (probably best to just
do this via calling pttodo-cli from script or somethin) (probably at an off hour do this via calling pttodo-cli from script or somethin) (probably at an off hour
@ -7,7 +9,6 @@ todo:
- what do about todo-now vs todo vs watch vs later... could do many files and manage - what do about todo-now vs todo vs watch vs later... could do many files and manage
outside binary, but search would suck. Good would be vendor lockin, and that's UI outside binary, but search would suck. Good would be vendor lockin, and that's UI
problem problem
- add tag anti-search, like -tag=-notMe
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I - todo: when to run scheduled modifier? like, syncthing could have conflicts if I
modify only file on remote modify only file on remote
details: | details: |
@ -26,6 +27,8 @@ todo:
- xactions emails extend ledger,todo-server with pttodo - schedule merge inbox style - xactions emails extend ledger,todo-server with pttodo - schedule merge inbox style
scheduled: [] scheduled: []
done: done:
- todo: add tag anti-search, like -tag=-notMe
ts: Tue Jan 4 06:56:03 EST 2022
- todo: if in todo, then omit ts field - todo: if in todo, then omit ts field
ts: Sun Jan 2 20:44:27 EST 2022 ts: Sun Jan 2 20:44:27 EST 2022
- todo: merge full files to import from todo-server - todo: merge full files to import from todo-server