Author: Kevin Schoon [me@kevinschoon.com]
Hash: 353e4196b21ddecca492cd79b79babddb86e296c
Timestamp: Sat, 18 Nov 2023 14:36:06 +0000 (10 months ago)

+8 -2 +/-1 browse
edit a daily note by default
1diff --git a/pkg/cmd/app.go b/pkg/cmd/app.go
2index 15d58fc..e67431e 100644
3--- a/pkg/cmd/app.go
4+++ b/pkg/cmd/app.go
5 @@ -5,6 +5,7 @@ import (
6 "fmt"
7 "os"
8 "path"
9+ "time"
10
11 "github.com/urfave/cli/v2"
12 "kevinschoon.com/projects/hierarchy/pkg/config"
13 @@ -20,6 +21,11 @@ func getConfigDir() string {
14 return path.Join(base, "hierarchy/config.yaml")
15 }
16
17+ func today() string {
18+ year, month, day := time.Now().Date()
19+ return fmt.Sprintf("/daily/%d-%d-%d", year, day, int(month))
20+ }
21+
22 func New() *cli.App {
23 cfg := config.Default()
24 app := cli.NewApp()
25 @@ -76,7 +82,7 @@ data structure. It uses SQLite to store note content and metadata.
26 Action: func(ctx *cli.Context) error {
27 path := ctx.Args().First()
28 if path == "" {
29- return fmt.Errorf("no path specified")
30+ path = today()
31 }
32 err := hierarchy.Create(*cfg, path)
33 if err != nil {
34 @@ -174,7 +180,7 @@ data structure. It uses SQLite to store note content and metadata.
35 Action: func(ctx *cli.Context) error {
36 path := ctx.Args().First()
37 if path == "" {
38- return fmt.Errorf("no path specified")
39+ path = today()
40 }
41 note, err := hierarchy.Find(*cfg, path)
42 if err != nil {