Skip to content

Commit 3d5da5f

Browse files
author
Takumasa Sakao
committed
Add presets & themes command
1 parent 55d8ee5 commit 3d5da5f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ func startGame(themes []Theme, presets []preset.Preset) error {
6161
return game.Loop()
6262
}
6363

64+
func listPresets(c *cli.Context, presets []preset.Preset) error {
65+
for _, preset := range presets {
66+
fmt.Println(preset.Name)
67+
}
68+
return nil
69+
}
70+
71+
func listThemes(c *cli.Context, themes []Theme) error {
72+
for _, theme := range themes {
73+
fmt.Println(theme.Name)
74+
}
75+
return nil
76+
}
77+
6478
func main() {
6579
presets, err := preset.LoadPresets()
6680
if err != nil {
@@ -81,6 +95,23 @@ func main() {
8195
app.Usage = "Conway's Game of Life"
8296
app.Version = "0.2.0"
8397

98+
app.Commands = []cli.Command{
99+
{
100+
Name: "themes",
101+
Usage: "list themes",
102+
Action: func(c *cli.Context) error {
103+
return listThemes(c, themes)
104+
},
105+
},
106+
{
107+
Name: "presets",
108+
Usage: "list presets",
109+
Action: func(c *cli.Context) error {
110+
return listPresets(c, presets)
111+
},
112+
},
113+
}
114+
84115
app.Action = func(c *cli.Context) error {
85116
return startGame(themes, presets)
86117
}

0 commit comments

Comments
 (0)