support -add-tags x,y,z

This commit is contained in:
Bel LaPointe
2023-04-24 15:02:13 -06:00
parent afc7d6001a
commit d105df15e9

View File

@@ -37,6 +37,7 @@ type config struct {
dry bool
add string
addSchedule string
addTags string
}
func main() {
@@ -53,10 +54,12 @@ func _main() error {
}
}
if config.add != "" {
if err := add(config.dry, config.targets, pttodo.Todo{
v := pttodo.Todo{
Todo: config.add,
Schedule: pttodo.Schedule(config.addSchedule),
}); err != nil {
Tags: config.addTags,
}
if err := add(config.dry, config.targets, v); err != nil {
return err
}
}
@@ -80,12 +83,13 @@ func getConfig() config {
flag.StringVar(&config.mergeme, "g", "", "path to yaml file to merge into -f (modifies f)")
flag.StringVar(&config.root, "root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")")
var tagss string
flag.StringVar(&tagss, "tags", "", "csv of all tags to find, -tag to invert")
flag.StringVar(&tagss, "tags", "", "csv of all tags to find, -x to invert")
flag.StringVar(&config.search, "search", "", "fts case insensitive")
flag.BoolVar(&config.edit, "e", false, "edit file")
flag.BoolVar(&config.dry, "dry", false, "dry run")
flag.StringVar(&config.add, "add", "", "todo to add")
flag.StringVar(&config.addSchedule, "add-schedule", "", "todo to add schedule")
flag.StringVar(&config.addTags, "add-tags", "", "todo to add csv tags")
flag.Parse()
config.tags = strings.Split(tagss, ",")