-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add embed lib to create and skaffold aoc projects
Signed-off-by: Rodolfo Sanchez <[email protected]>
- Loading branch information
Showing
9 changed files
with
91 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright © 2023 Rodolfo Sanchez <[email protected]> | ||
Copyright © 2024 Rodolfo Sanchez <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -22,29 +22,28 @@ THE SOFTWARE. | |
package aoctl | ||
|
||
import ( | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/dolfolife/aoctl/pkg/aoc" | ||
"github.com/dolfolife/aoctl/pkg/aoc" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var initCmd = &cobra.Command{ | ||
Use: "init", | ||
Aliases: []string{"initialize"}, | ||
Short: "Initialize the Advent of Code project in the path specifed", | ||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
path := cmd.Flags().Lookup("path").Value.String() | ||
|
||
if path == "" { | ||
path= "adventofcode" | ||
} | ||
|
||
aoc.InitializeProject(path) | ||
}, | ||
Use: "init", | ||
Aliases: []string{"initialize"}, | ||
Short: "Initialize the Advent of Code project in the path specifed", | ||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
path := cmd.Flags().Lookup("path").Value.String() | ||
|
||
if path == "" { | ||
path = "adventofcode" | ||
} | ||
|
||
aoc.InitializeProject(path) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(initCmd) | ||
rootCmd.AddCommand(initCmd) | ||
|
||
initCmd.Flags().StringP("path", "p", "", "Path to initialize the project") | ||
initCmd.Flags().StringP("path", "p", "", "Path to initialize the project") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Reference | ||
|
||
|
||
### Project Structure | ||
|
||
The key part of the project is to organize all the advent of code events by year. Each year will const of a matrix of days and problems (2 problems per day). | ||
|
||
```bash | ||
.env # environment variables file | ||
adventofcode.yaml # configuration file for the project | ||
README.md # | ||
events/ # root of all the years of advent of code you have worked on | ||
<year>/ | ||
<day>/ | ||
<solution-files> # Test and code of your solutions | ||
inputs/ # inputs for testing and submiting the anwser online | ||
metadata.yaml # information of the current state of your solution | ||
README.md # Description of the problems (cache from adventofcode.com/year/day) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package aoc | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"log" | ||
) | ||
|
||
//go:embed templates | ||
var templates embed.FS | ||
|
||
func GetRootFile(filename string) string { | ||
data, err := templates.ReadFile(fmt.Sprintf("templates/root/%s", filename)) | ||
|
||
if err != nil { | ||
log.Fatalf("error reading %s template with: \n%v\n", filename, err) | ||
} | ||
|
||
return string(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Advent of Code Solutions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Use the .env file to set the environment variables for your project | ||
AOC_SESSION=<insert-advent-of-code-session> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |