refactor(race): replace :CP race subcommand with --race flag

Problem: Race was the only command using `:CP <action> <platform> <contest>`.
Every other platform+contest command uses `:CP <platform> <contest> [flags]`.

Solution: Make race a flag on contest setup: `:CP <platform> <contest> --race`.
Remove `:CP race stop` — starting a new race auto-cancels any active one.
Remove `<Plug>(cp-race-stop)` keymap. Update tab completion for `--race`.
This commit is contained in:
Barrett Ruth 2026-03-06 18:26:05 -05:00
parent 58b6840815
commit 80f2853999
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 68 additions and 75 deletions

View file

@ -39,8 +39,7 @@ function M.start(platform, contest_id, language)
return
end
if race_state.timer then
logger.log('Race already active. Use :CP race stop first.', { level = vim.log.levels.WARN })
return
M.stop()
end
cache.load()
@ -48,7 +47,7 @@ function M.start(platform, contest_id, language)
local display = constants.PLATFORM_DISPLAY_NAMES[platform] or platform
local cached_countdown = cache.get_supports_countdown(platform)
if cached_countdown == false then
logger.log(('%s does not support :CP race'):format(display), { level = vim.log.levels.ERROR })
logger.log(('%s does not support --race'):format(display), { level = vim.log.levels.ERROR })
return
end
@ -65,7 +64,7 @@ function M.start(platform, contest_id, language)
if sc == false then
cache.set_contest_summaries(platform, result.contests or {}, { supports_countdown = false })
logger.log(
('%s does not support :CP race'):format(display),
('%s does not support --race'):format(display),
{ level = vim.log.levels.ERROR }
)
return
@ -138,7 +137,6 @@ end
function M.stop()
local timer = race_state.timer
if not timer then
logger.log('No active race', { level = vim.log.levels.WARN })
return
end
timer:stop()
@ -149,7 +147,6 @@ function M.stop()
race_state.contest_name = nil
race_state.language = nil
race_state.start_time = nil
logger.log('Race cancelled', { level = vim.log.levels.INFO, override = true })
end
function M.status()