refactor: replace :CP login with :CP credentials subcommand

Problem: :CP login was a poor API — no way to clear credentials without
raw Lua, and the single command didn't scale to multiple operations.

Solution: replace login with a :CP credentials subcommand following the
same pattern as :CP cache. :CP credentials set [platform] prompts and
saves; :CP credentials clear [platform] removes one or all platforms.
Add cache.clear_credentials(), rename login.lua to credentials.lua,
update parse/dispatch/tab-complete, and rewrite vimdoc accordingly.
This commit is contained in:
Barrett Ruth 2026-03-03 16:42:35 -05:00 committed by Barrett Ruth
parent 3e0b7beabf
commit a04702d87c
6 changed files with 88 additions and 32 deletions

View file

@ -103,8 +103,8 @@ end, {
end
end
return filter_candidates(candidates)
elseif args[2] == 'login' then
return filter_candidates(platforms)
elseif args[2] == 'credentials' then
return filter_candidates({ 'set', 'clear' })
elseif args[2] == 'race' then
local candidates = { 'stop' }
vim.list_extend(candidates, platforms)
@ -126,6 +126,8 @@ end, {
cache.load()
local contests = cache.get_cached_contest_ids(args[3])
return filter_candidates(contests)
elseif args[2] == 'credentials' and vim.tbl_contains({ 'set', 'clear' }, args[3]) then
return filter_candidates(platforms)
elseif args[2] == 'cache' and args[3] == 'clear' then
local candidates = vim.list_extend({}, platforms)
table.insert(candidates, '')