module Aocli

Constants

VERSION

Public Instance Methods

start_cli() click to toggle source
# File lib/aocli.rb, line 18
def start_cli
  Aocli::CLI.start
end
submit_answer(answer) click to toggle source
# File lib/aocli.rb, line 22
def submit_answer(answer)
  year, day, part_file = caller_locations[-1].to_s.split(" ")[0].split("/")[-3..]
  if part_file.include?("part_one")
    level = 1
  elsif part_file.include?("part_two")
    level = 2
  else
    raise(ArgumentError, "Called from a location not generated by aocli")
  end
  result = Aocli::Adapter.submit_answer(
    year: year,
    day: day,
    level: level,
    answer: answer,
  )

  if result == :no_token
    puts "It looks like something is wrong with your session token and Aocli was unable to submit your answer. Please try resetting your token before submitting again."
  elsif result == :too_soon
    puts "Please wait some time before submitting again"
  elsif result == :incorrect
    puts "Incorrect answer"
  elsif result == :correct
    puts "Correct! Problem code has been updated."
  end
end