From 9b2ba11adade07e6582d29a29dadc7ee4aef55fe Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 2 Jul 2014 15:02:56 -0400 Subject: [PATCH] adding README and next-note --- README.md | 22 ++++++++++++++++++++++ cmd/next-note/main.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 README.md create mode 100644 cmd/next-note/main.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9f89bf --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# freezing-octo-hipster + +Random utilities of vbatts' being cleaned up, and published + +# Commands + +## next-note + +Simple date formating for notes + +### Install + + go get github.com/vbatts/freezing-octo-hipster/cmd/next-note + +## find-todos + +Look through your notes directory for TODO items. + +### Install + + go get github.com/vbatts/freezing-octo-hipster/cmd/find-todos + diff --git a/cmd/next-note/main.go b/cmd/next-note/main.go new file mode 100644 index 0000000..f547b20 --- /dev/null +++ b/cmd/next-note/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "flag" + "fmt" + "path" + "time" +) + +var ( + flDir = flag.String("dir", "", "Base directory for tasks") + flDate = flag.Bool("d", false, "print current date") + flPrevWeek = flag.Bool("p", false, "print previous week's filename") + flCurrWeek = flag.Bool("c", false, "print current week's filename") +) + +var FileDate = "20060102" + +func main() { + flag.Parse() + + if *flDate { + fmt.Println(time.Now().Format(time.UnixDate)) + return + } + + var monday int + t := time.Now() + if *flCurrWeek { + monday = -1*int(t.Weekday()) + 1 + } else if *flPrevWeek { + monday = -1*int(t.Weekday()) + 1 - 7 + } else { + monday = -1*int(t.Weekday()) + 1 + 7 + } + friday := monday + 4 + startDate := t.AddDate(0, 0, monday).Format(FileDate) + endDate := t.AddDate(0, 0, friday).Format(FileDate) + filename := fmt.Sprintf("Tasks-%s-%s.txt", startDate, endDate) + fmt.Println(path.Join(*flDir, filename)) +}