Skip to content

Commit

Permalink
Update README and other minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
csessh committed Jan 13, 2025
1 parent 2260524 commit b4dce6f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 42 deletions.
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ In the true developer fashion, I started with one task to solve Advent of Code p

## Disclaimer

This plugin follows the automation guidelines on the `r/adventofcode` [community wiki](https://www.reddit.com/r/adventofcode/wiki/faqs/automation).
This plugin follows the guidelines on the `r/adventofcode` [community wiki](https://www.reddit.com/r/adventofcode/wiki/faqs/automation).

Specifically:

- Outbound calls are throttled to every 5 minutes.
- Once inputs are downloaded, they are cached locally.
- If you suspect your input is corrupted, you can manually clear cache and request new input with `:AocClearCache`
- The User-Agent header used in HTTP requests is set to me since I maintain this tool.
Expand Down
2 changes: 1 addition & 1 deletion lua/aoc/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local cfg = require "aoc.config"
---@class APIWrapper
local M = {}
M.session_id = nil
M.user_agent = "github.com/csessh/aoc.nvim by [email protected]"
M.user_agent = "<github.com/csessh/aoc.nvim> by [email protected]"

---@param day string|osdate
---@param year string|osdate
Expand Down
7 changes: 2 additions & 5 deletions lua/aoc/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,18 @@ M.write_to_cache = function(day, year, content)
vim.api.nvim_err_writeln("Unable to write puzzle input to cache at " .. filename)
else
f:write(content)
f:close()
end

f:close()
end

---Write puzzle input to user's cwd() or where they specify it otherwise
---@param day string|osdate
---@param year string|osdate
---@param content string
M.write_to_file = function(day, year, content)
local filename = ""
local filename = cfg.options.puzzle_input.alternative_filepath
if cfg.options.puzzle_input.save_to_current_dir then
filename = vim.uv.cwd() .. "/" .. cfg.options.puzzle_input.filename
else
filename = cfg.options.puzzle_input.alternative_filepath
end

---@diagnostic disable-next-line: param-type-mismatch
Expand Down
23 changes: 0 additions & 23 deletions lua/aoc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ M.setup = function(args)
api.save_puzzle_input(day, year)
end, {})

vim.api.nvim_create_user_command("AocSubmitAnswer", function()
local day = vim.fn.input "Day: "
local year = vim.fn.input "Year: "
local answer = vim.fn.input "Answer: "
vim.api.nvim_out_write "\n"

day = utils.trim(day)
year = utils.trim(year)
answer = utils.trim(answer)

api.submit_answer(day, year, answer)
end, {})

vim.api.nvim_create_user_command("AocSubmitTodayAnswer", function()
local day = os.date "%d"
local year = os.date "%Y"

local answer = vim.fn.input "Answer: "
vim.api.nvim_out_write "\n"

api.submit_answer(day, year, answer)
end, {})

vim.api.nvim_create_user_command("AocClearCache", cache.clear_cache, {})
vim.api.nvim_create_user_command("AocInspectConfig", cfg.debug, {})
end
Expand Down

0 comments on commit b4dce6f

Please sign in to comment.