lib/aocli/commands/start_day.rb in aocli-1.4.5 vs lib/aocli/commands/start_day.rb in aocli-1.5.0
- old
+ new
@@ -21,26 +21,34 @@
File.write(main_file_path, main_content)
File.write(input_file_path, input_content)
end
private
+
attr_reader :date, :output_destination, :main_file_path, :input_file_path
def main_content
problem_description = Aocli::AdventOfCode.get_problem_description(
year: date.year,
day: date.day,
)
- content = Aocli::FileUtils.insert_lines(
+ problem_description = "Part One Description\n" + problem_description
+
+ template_file = Aocli::Config.value_for(:template_path) || File.join(__dir__, "../content/main.txt")
+ unless File.exist?(template_file)
+ template_file = File.join(__dir__, "../content/main.txt")
+ end
+
+ content = Aocli::FileUtils.replace_line(
+ File.read(template_file),
+ "__aocli_problem_description__",
Aocli::FileUtils.wrap_lines(problem_description).split("\n").map { _1 == "" ? "#" : "# #{_1}" },
- into: File.read(File.join(__dir__, "../content/main.txt")),
- after: "##### Part One Description #####",
)
Aocli::FileUtils.replace_line(
content,
- "# __load_input__",
+ "__aocli_load_input__",
'input = File.read(__FILE__.gsub("main.rb", "input.txt"))'
)
end
def input_content