Compare commits
No commits in common. "c13456b3adbf09b3e77e96539f5e1f3b1ea030ae" and "a67e0d5db8de3e1abc52f0b7262f2f9bd614da32" have entirely different histories.
c13456b3ad
...
a67e0d5db8
1 changed files with 2 additions and 33 deletions
|
|
@ -25,20 +25,6 @@ local actions = constants.ACTIONS
|
|||
---@field language? string
|
||||
---@field subcommand? string
|
||||
|
||||
---@param str string
|
||||
---@return string
|
||||
local function canonicalize_cf_contest(str)
|
||||
local id = str:match('/contest/(%d+)') or str:match('/problemset/problem/(%d+)')
|
||||
if id then
|
||||
return id
|
||||
end
|
||||
local num = str:match('^(%d+)[A-Za-z]')
|
||||
if num then
|
||||
return num
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
--- Turn raw args into normalized structure to later dispatch
|
||||
---@param args string[] The raw command-line mode args
|
||||
---@return ParsedCommand
|
||||
|
|
@ -260,24 +246,16 @@ local function parse_command(args)
|
|||
if args[2] == 'login' or args[2] == 'logout' then
|
||||
return { type = 'action', action = args[2], platform = first }
|
||||
end
|
||||
local contest = args[2]
|
||||
if first == 'codeforces' then
|
||||
contest = canonicalize_cf_contest(contest)
|
||||
end
|
||||
return {
|
||||
type = 'contest_setup',
|
||||
platform = first,
|
||||
contest = contest,
|
||||
contest = args[2],
|
||||
}
|
||||
elseif #args == 4 and args[3] == '--lang' then
|
||||
local contest = args[2]
|
||||
if first == 'codeforces' then
|
||||
contest = canonicalize_cf_contest(contest)
|
||||
end
|
||||
return {
|
||||
type = 'contest_setup',
|
||||
platform = first,
|
||||
contest = contest,
|
||||
contest = args[2],
|
||||
language = args[4],
|
||||
}
|
||||
else
|
||||
|
|
@ -318,15 +296,6 @@ function M.handle_command(opts)
|
|||
local restore = require('cp.restore')
|
||||
restore.restore_from_current_file()
|
||||
elseif cmd.type == 'action' then
|
||||
local CONTEST_ACTIONS =
|
||||
{ 'run', 'panel', 'edit', 'interact', 'stress', 'submit', 'next', 'prev', 'pick' }
|
||||
if vim.tbl_contains(CONTEST_ACTIONS, cmd.action) and not state.get_platform() then
|
||||
local restore = require('cp.restore')
|
||||
if not restore.restore_from_current_file() then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local setup = require('cp.setup')
|
||||
local ui = require('cp.ui.views')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue