feat(cli): :CP <problem_id>
This commit is contained in:
parent
91864b2992
commit
44bfc7317d
3 changed files with 41 additions and 12 deletions
|
|
@ -23,22 +23,26 @@ end, {
|
|||
if num_args == 2 then
|
||||
local candidates = {}
|
||||
local state = require('cp.state')
|
||||
local platform, contest_id = state.get_platform(), state.get_contest_id()
|
||||
local platform = state.get_platform()
|
||||
local contest_id = state.get_contest_id()
|
||||
|
||||
if platform and contest_id then
|
||||
vim.list_extend(candidates, actions)
|
||||
local cache = require('cp.cache')
|
||||
cache.load()
|
||||
local contest_data = cache.get_contest_data(platform, contest_id)
|
||||
if contest_data and contest_data.problems then
|
||||
for _, problem in ipairs(contest_data.problems) do
|
||||
table.insert(candidates, problem.id)
|
||||
end
|
||||
|
||||
if contest_data and contest_data.index_map then
|
||||
local ids = vim.tbl_keys(contest_data.index_map)
|
||||
table.sort(ids)
|
||||
vim.list_extend(candidates, ids)
|
||||
end
|
||||
else
|
||||
vim.list_extend(candidates, platforms)
|
||||
table.insert(candidates, 'cache')
|
||||
table.insert(candidates, 'pick')
|
||||
end
|
||||
|
||||
return vim.tbl_filter(function(cmd)
|
||||
return cmd:find(ArgLead, 1, true) == 1
|
||||
end, candidates)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue