28 lines
862 B
Ruby
28 lines
862 B
Ruby
require "tty-prompt"
|
|
require "tty-file"
|
|
require "ostruct"
|
|
|
|
require_relative("templates")
|
|
|
|
def new_day(prompt, day)
|
|
input = prompt.multiline("Example input").join("")
|
|
print input
|
|
result = prompt.ask("Example result")
|
|
|
|
day_name = "day_#{day}"
|
|
|
|
TTY::File.create_dir(day_name)
|
|
TTY::File.create_file("#{day_name}/data")
|
|
TTY::File.create_file("#{day_name}/impl.rb", IMPL_RB)
|
|
TTY::File.create_file("#{day_name}/run.rb", RUN_RB)
|
|
TTY::File.create_file("#{day_name}/test.rb", TEST_RB)
|
|
|
|
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
|