Skip to content

Commit 56c2e4c

Browse files
authored
feat: Enhance boilerplate generator (#333)
1 parent 2ffcefb commit 56c2e4c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

internal/puzzles/solutions/new.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func createNewFromTemplate(purl string) error {
1414
const (
15-
perms = 0o655
15+
perms = os.ModePerm
1616
yearLen = 4
1717
dayLen = 2
1818
)
@@ -38,10 +38,13 @@ func createNewFromTemplate(purl string) error {
3838
}
3939

4040
params := templates.Params{
41-
Year: year,
42-
Day: pd.day,
43-
DayStr: day,
44-
URL: purl,
41+
Year: year,
42+
Day: pd.day,
43+
DayStr: day,
44+
URL: purl,
45+
Title: "<!--- Pass here the title --->",
46+
DescriptionPartOne: "<!--- Pass here the description for part one --->",
47+
DescriptionPartTwo: "<!--- Pass here the description for part two --->",
4548
}
4649

4750
path := filepath.Clean(filepath.Join(year, "day"+day))

internal/puzzles/solutions/templates/embed.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ var (
1919

2020
// Params contains parameters for templates.
2121
type Params struct {
22-
Year string // e.g. "2023"
23-
Day int // e.g. 2
24-
DayStr string // e.g. "02"
25-
URL string // e.g. "https://adventofcode.com/2023/day/2"
22+
Year string // e.g. "2023"
23+
Day int // e.g. 2
24+
DayStr string // e.g. "02"
25+
URL string // e.g. "https://adventofcode.com/2023/day/2"
26+
Title string // For now it's empty.
27+
DescriptionPartOne string // For now it's empty.
28+
DescriptionPartTwo string // For now it's empty.
2629
}
2730

2831
// SolutionTmpl returns template for solution.go file.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
# Puzzle {{ .URL }}
12

3+
# --- Day {{ .Day }}: {{ .Title }} ---
4+
5+
## --- Part One ---
6+
7+
{{ .DescriptionPartOne }}
8+
9+
## --- Part Two ---
10+
11+
{{ .DescriptionPartTwo }}
212

0 commit comments

Comments
 (0)