3 Commits

Author SHA1 Message Date
Bel LaPointe
f7dac79233 pttodo-cli default file via env 2021-12-31 22:07:16 -05:00
Bel LaPointe
8c45d4a7df pttodo-cli works even if file does not initially exist 2021-12-31 22:05:47 -05:00
Bel LaPointe
1e3f24b4d5 rename gomod, root project 2021-12-31 21:58:02 -05:00
4 changed files with 16 additions and 10 deletions

View File

@@ -22,7 +22,11 @@ func main() {
}
func _main() error {
filepath := flag.String("f", "-", "path to yaml file")
defaultFilepath, ok := os.LookupEnv("PTTODO_FILE")
if !ok {
defaultFilepath = "-"
}
filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file")
e := flag.Bool("e", false, "edit file")
flag.Parse()
if *e {
@@ -40,6 +44,7 @@ func edit(filepath string) error {
if err != nil {
return err
}
if _, err := os.Stat(filepath); err == nil {
g, err := os.Open(filepath)
if err != nil {
return err
@@ -48,6 +53,7 @@ func edit(filepath string) error {
return err
}
g.Close()
}
f.Close()
tempFile = f.Name()
return nil

View File

@@ -1,4 +1,4 @@
module pttodo
module pttodo-cli
go 1.17

2
go.mod
View File

@@ -1,4 +1,4 @@
module local/pt-todo-server
module pttodo
go 1.17