first version of aoc helper
This commit is contained in:
21
app/tasks/new_day.rb
Normal file
21
app/tasks/new_day.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require "tty-prompt"
|
||||
require "tty-file"
|
||||
require "ostruct"
|
||||
|
||||
def new_day(prompt, day)
|
||||
input = prompt.multiline("Example input").join("")
|
||||
print input
|
||||
result = prompt.ask("Example result")
|
||||
|
||||
day_name = "day_#{day}"
|
||||
|
||||
TTY::File.copy_directory("app/templates","#{day_name}")
|
||||
|
||||
TTY::File.replace_in_file "#{day_name}/run.rb", /%day_name%/, day_name
|
||||
TTY::File.replace_in_file "#{day_name}/test.rb", /%day_name%/, day_name
|
||||
TTY::File.replace_in_file "#{day_name}/test.rb", /%example_result%/, result
|
||||
TTY::File.replace_in_file "#{day_name}/test.rb", /%example_input%/, input
|
||||
|
||||
puts "Done - run with:"
|
||||
puts "ruby #{day_name}/test.rb"
|
||||
end
|
||||
5
app/tasks/part_two.rb
Normal file
5
app/tasks/part_two.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require "tty-prompt"
|
||||
|
||||
def part_two(prompt, day)
|
||||
prompt.say("part two not yet supported")
|
||||
end
|
||||
Reference in New Issue
Block a user