14 Commits

Author SHA1 Message Date
Bel LaPointe
d9cb376c11 gitignore 2022-09-10 11:25:23 -06:00
Bel LaPointe
47f46a8d78 no prior file exists ok 2022-09-10 11:24:41 -06:00
Bel LaPointe
f90124ca27 on scheduled task done, in addition to requeue, add to done 2022-09-10 11:13:18 -06:00
Bel LaPointe
976f5bf073 quick add via cli -add, -add-schedule 2022-04-07 12:48:17 -06:00
Bel LaPointe
ac3dc241f1 root moves fixed future schedules to shceduled on automove 2022-03-24 14:43:45 -06:00
Bel LaPointe
e913c9cd3c revert to clean todo 2022-03-24 09:26:44 -06:00
Bel LaPointe
02e4c95d31 revert automove for crons 2022-03-24 09:25:34 -06:00
Bel LaPointe
bbdd38fba7 always write ts, when a todo with schedule deleted, conditionally go back to schedule for loopers 2022-03-24 09:18:19 -06:00
Bel LaPointe
4bdee5d9a0 cli on delete todo, write in Done identified by entire struct so dupes wouldnt but thats ok 2022-03-23 09:46:16 -06:00
Bel LaPointe
7c84d7650c add todo.ID() 2022-03-23 09:42:21 -06:00
Bel LaPointe
29646808f9 ready for find deleted 2022-03-23 08:06:57 -06:00
Bel LaPointe
8276308d52 if item in todo is scheduled for later, then move it 2022-03-23 08:04:35 -06:00
Bel LaPointe
8c050d1d89 new edit ready for shuffles 2022-03-23 07:49:54 -06:00
Bel LaPointe
e8a83176aa getconfig in pttodo-cli 2022-03-23 07:27:49 -06:00
5 changed files with 31 additions and 36 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"local/pt-todo-server/pttodo"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@@ -15,10 +16,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/google/uuid"
"gogs.inhome.blapointe.com/bel/pttodo/pttodo"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@@ -39,7 +36,6 @@ type config struct {
dry bool dry bool
add string add string
addSchedule string addSchedule string
addTags string
} }
func main() { func main() {
@@ -56,12 +52,10 @@ func _main() error {
} }
} }
if config.add != "" { if config.add != "" {
v := pttodo.Todo{ if err := add(config.dry, config.targets, pttodo.Todo{
Todo: config.add, Todo: config.add,
Schedule: pttodo.Schedule(config.addSchedule), Schedule: pttodo.Schedule(config.addSchedule),
Tags: config.addTags, }); err != nil {
}
if err := add(config.dry, config.targets, v); err != nil {
return err return err
} }
} }
@@ -74,8 +68,8 @@ func _main() error {
} }
func getConfig() config { func getConfig() config {
defaultFilepath := os.Getenv("PTTODO_FILE") defaultFilepath, ok := os.LookupEnv("PTTODO_FILE")
if defaultFilepath == "" { if !ok {
defaultFilepath = "./todo.yaml" defaultFilepath = "./todo.yaml"
} }
@@ -85,13 +79,12 @@ func getConfig() config {
flag.StringVar(&config.mergeme, "g", "", "path to yaml file to merge into -f (modifies f)") 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})+")") 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 var tagss string
flag.StringVar(&tagss, "tags", "", "csv of all tags to find, -x to invert") flag.StringVar(&tagss, "tags", "", "csv of all tags to find, -tag to invert")
flag.StringVar(&config.search, "search", "", "fts case insensitive") flag.StringVar(&config.search, "search", "", "fts case insensitive")
flag.BoolVar(&config.edit, "e", false, "edit file") flag.BoolVar(&config.edit, "e", false, "edit file")
flag.BoolVar(&config.dry, "dry", false, "dry run") flag.BoolVar(&config.dry, "dry", false, "dry run")
flag.StringVar(&config.add, "add", "", "todo to add") flag.StringVar(&config.add, "add", "", "todo to add")
flag.StringVar(&config.addSchedule, "add-schedule", "", "todo to add schedule") flag.StringVar(&config.addSchedule, "add-schedule", "", "todo to add schedule")
flag.StringVar(&config.addTags, "add-tags", "", "todo to add csv tags")
flag.Parse() flag.Parse()
config.tags = strings.Split(tagss, ",") config.tags = strings.Split(tagss, ",")
@@ -162,7 +155,6 @@ func edit(dry bool, filepaths []string) error {
return err return err
} }
originals := map[string]pttodo.Root{} originals := map[string]pttodo.Root{}
lastModified := map[string]time.Time{}
for _, target := range filepaths { for _, target := range filepaths {
var original pttodo.Root var original pttodo.Root
if r, err := filePathReader(target); err != nil { if r, err := filePathReader(target); err != nil {
@@ -175,11 +167,6 @@ func edit(dry bool, filepaths []string) error {
return err return err
} }
originals[target] = original originals[target] = original
if info, _ := os.Stat(target); info != nil {
lastModified[target] = info.ModTime()
} else {
lastModified[target] = time.Time{}
}
} }
if err := vimd(tempDir); err != nil { if err := vimd(tempDir); err != nil {
return err return err
@@ -244,11 +231,7 @@ func edit(dry bool, filepaths []string) error {
if err != nil { if err != nil {
return err return err
} }
outputPath := target if err := ioutil.WriteFile(target, c, os.ModePerm); err != nil {
if info, _ := os.Stat(target); info != nil && info.ModTime() != lastModified[target] {
outputPath = fmt.Sprintf("%s.%s.%s", outputPath, uuid.New().String(), path.Ext(outputPath))
}
if err := ioutil.WriteFile(outputPath, c, os.ModePerm); err != nil {
return err return err
} }
} }
@@ -573,9 +556,6 @@ func listDir(dname string) ([]string, error) {
if entries[i].IsDir() { if entries[i].IsDir() {
continue continue
} }
if strings.HasPrefix(path.Base(entries[i].Name()), ".") {
continue
}
paths = append(paths, path.Join(dname, entries[i].Name())) paths = append(paths, path.Join(dname, entries[i].Name()))
} }
sort.Slice(paths, func(i, j int) bool { sort.Slice(paths, func(i, j int) bool {

View File

@@ -3,13 +3,10 @@ module pttodo-cli
go 1.17 go 1.17
require ( require (
gogs.inhome.blapointe.com/bel/pttodo v0.4.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
local/pt-todo-server v0.0.0-00010101000000-000000000000
) )
require ( require github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
)
replace gogs.inhome.blapointe.com/bel/pttodo => ../.. replace local/pt-todo-server => ../../

View File

@@ -1,5 +1,3 @@
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

10
go.mod
View File

@@ -1,4 +1,4 @@
module gogs.inhome.blapointe.com/bel/pttodo module pttodo
go 1.17 go 1.17
@@ -6,3 +6,11 @@ require (
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
) )
require (
github.com/bytbox/go-pop3 v0.0.0-20120201222208-3046caf0763e // indirect
github.com/emersion/go-imap v1.2.0 // indirect
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect
golang.org/x/text v0.3.7 // indirect
)

12
go.sum
View File

@@ -1,5 +1,17 @@
github.com/bytbox/go-pop3 v0.0.0-20120201222208-3046caf0763e h1:mQTN05gz0rDZSABqKMzAPMb5ATWcvvdMljRzEh0LjBo=
github.com/bytbox/go-pop3 v0.0.0-20120201222208-3046caf0763e/go.mod h1:alXX+s7a4cKaIprgjeEboqi4Tm7XR/HXEwUTxUV/ywU=
github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA=
github.com/emersion/go-imap v1.2.0/go.mod h1:Qlx1FSx2FTxjnjWpIlVNEuX+ylerZQNFE5NsmKFSejY=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 h1:OJyUGMJTzHTd1XQp98QTaHernxMYzRaOasRir9hUlFQ=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=