-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
80 lines (71 loc) · 1.6 KB
/
main.go
File metadata and controls
80 lines (71 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"log"
"os"
"time"
"github.com/stoneream/diary-generator/v2/cmd/archive"
"github.com/stoneream/diary-generator/v2/cmd/initialize"
"github.com/stoneream/diary-generator/v2/cmd/summary"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "diary-generator",
Usage: "diary-generator [init | archive]",
Version: Version,
Flags: []cli.Flag{},
Commands: []*cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "Initialize a diary",
Action: func(c *cli.Context) error {
cmd := initialize.InitializeCmd{
Now: time.Now(),
}
return cmd.Execute()
},
},
{
Name: "archive",
Aliases: []string{"a"},
Usage: "Archive a diary",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "target-ym",
Usage: "target year and month (e.g. 2024-01)",
Required: true,
},
},
Action: func(c *cli.Context) error {
targetYM := c.String("target-ym")
cmd := archive.ArchiveCmd{
TargetYM: targetYM,
}
return cmd.Execute()
},
},
{
Name: "summary",
Aliases: []string{"s"},
Usage: "Create a summary",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "target-prefix",
Usage: "target prefix (diary_, default: current directory name)",
},
},
Action: func(c *cli.Context) error {
targetPrefix := c.String("target-prefix")
cmd := summary.SummaryCmd{
TargetPrefixOpt: targetPrefix,
}
return cmd.Execute()
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}