mirror of
https://github.com/vbatts/freezing-octo-hipster.git
synced 2024-11-25 08:15:39 +00:00
adding README and next-note
This commit is contained in:
parent
4c3cae91dd
commit
9b2ba11ada
2 changed files with 63 additions and 0 deletions
22
README.md
Normal file
22
README.md
Normal file
|
@ -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
|
||||
|
41
cmd/next-note/main.go
Normal file
41
cmd/next-note/main.go
Normal file
|
@ -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))
|
||||
}
|
Loading…
Reference in a new issue