Skip to content

Commit

Permalink
feat: Enhance boilerplate generator (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
obalunenko authored Nov 25, 2024
1 parent 2ffcefb commit 56c2e4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
13 changes: 8 additions & 5 deletions internal/puzzles/solutions/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func createNewFromTemplate(purl string) error {
const (
perms = 0o655
perms = os.ModePerm
yearLen = 4
dayLen = 2
)
Expand All @@ -38,10 +38,13 @@ func createNewFromTemplate(purl string) error {
}

params := templates.Params{
Year: year,
Day: pd.day,
DayStr: day,
URL: purl,
Year: year,
Day: pd.day,
DayStr: day,
URL: purl,
Title: "<!--- Pass here the title --->",
DescriptionPartOne: "<!--- Pass here the description for part one --->",
DescriptionPartTwo: "<!--- Pass here the description for part two --->",
}

path := filepath.Clean(filepath.Join(year, "day"+day))
Expand Down
11 changes: 7 additions & 4 deletions internal/puzzles/solutions/templates/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ var (

// Params contains parameters for templates.
type Params struct {
Year string // e.g. "2023"
Day int // e.g. 2
DayStr string // e.g. "02"
URL string // e.g. "https://adventofcode.com/2023/day/2"
Year string // e.g. "2023"
Day int // e.g. 2
DayStr string // e.g. "02"
URL string // e.g. "https://adventofcode.com/2023/day/2"
Title string // For now it's empty.
DescriptionPartOne string // For now it's empty.
DescriptionPartTwo string // For now it's empty.
}

// SolutionTmpl returns template for solution.go file.
Expand Down
10 changes: 10 additions & 0 deletions internal/puzzles/solutions/templates/spec.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# Puzzle {{ .URL }}

# --- Day {{ .Day }}: {{ .Title }} ---

## --- Part One ---

{{ .DescriptionPartOne }}

## --- Part Two ---

{{ .DescriptionPartTwo }}

0 comments on commit 56c2e4c

Please sign in to comment.