Skip to content

Commit c3cb0e2

Browse files
committed
fix!: remove deprecated commands
1 parent 9aaf282 commit c3cb0e2

3 files changed

Lines changed: 4 additions & 66 deletions

File tree

lua/competitest/commands.lua

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,6 @@ local utils = require("competitest.utils")
55
local widgets = require("competitest.widgets")
66
local M = {}
77

8-
---Warn users about deprecated commands
9-
---@param old_cmd string
10-
---@param new_cmd string
11-
---@param qargs string
12-
function M.deprecated_commands(old_cmd, new_cmd, qargs)
13-
utils.notify(
14-
string.format(
15-
"the command 'CompetiTest%s' is deprecated and it will be removed soon.\nPlease use the new 'CompetiTest %s' command.",
16-
old_cmd,
17-
new_cmd
18-
),
19-
"WARN"
20-
)
21-
vim.defer_fn(function()
22-
M.command(new_cmd .. " " .. qargs)
23-
end, 5000)
24-
end
25-
268
---Handle CompetiTest subcommands
279
---@param args string: command line arguments
2810
function M.command(args)

lua/competitest/config.lua

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,44 +156,14 @@ function M.update_config_table(cfg_tbl, opts)
156156
return vim.deepcopy(cfg_tbl or default_config)
157157
end
158158

159+
--[[
160+
-- check deprecated options
159161
local function notify_warning(msg)
160162
vim.schedule(function()
161163
vim.notify("CompetiTest.nvim: " .. msg, vim.log.levels.WARN, { title = "CompetiTest" })
162164
end)
163165
end
164-
165-
-- check deprecated testcases options
166-
if opts.testcases_files_format then
167-
opts.testcases_input_file_format = string.gsub(opts.testcases_files_format, "%$%(INOUT%)", opts.input_name or "input")
168-
opts.testcases_output_file_format = string.gsub(opts.testcases_files_format, "%$%(INOUT%)", opts.output_name or "output")
169-
opts.testcases_files_format = nil
170-
notify_warning(
171-
"option 'testcases_files_format' has been deprecated in favour of 'testcases_input_file_format' and 'testcases_output_file_format'."
172-
)
173-
end
174-
if opts.input_name then
175-
opts.input_name = nil
176-
notify_warning("option 'input_name' has been deprecated. See 'testcases_input_file_format'.")
177-
end
178-
if opts.output_name then
179-
opts.output_name = nil
180-
notify_warning("option 'output_name' has been deprecated. See 'testcases_output_file_format'.")
181-
end
182-
-- check deprecated ui options
183-
if opts.runner_ui then
184-
for _, option in ipairs({ "total_width", "total_height" }) do
185-
if opts.runner_ui[option] then
186-
opts.popup_ui = opts.popup_ui or {}
187-
opts.popup_ui[option] = opts.runner_ui[option]
188-
opts.runner_ui[option] = nil
189-
notify_warning("option 'runner_ui." .. option .. "' has been deprecated in favour of 'popup_ui." .. option .. "'.")
190-
end
191-
end
192-
if opts.runner_ui.selector_width then
193-
opts.runner_ui.selector_width = nil
194-
notify_warning("option 'runner_ui.selector_width' has been deprecated. See 'popup_ui.layout'.")
195-
end
196-
end
166+
]]
197167

198168
local new_config = vim.tbl_deep_extend("force", cfg_tbl or default_config, opts)
199169
-- commands arguments lists need to be replaced and not extended

lua/competitest/init.lua

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function M.setup(opts)
99
if not config.current_setup.loaded then
1010
config.current_setup.loaded = true
1111

12-
-- CompetiTest commands
12+
-- CompetiTest command
1313
vim.cmd([[
1414
function! s:command_completion(_, CmdLine, CursorPos) abort
1515
let prefix = a:CmdLine[:a:CursorPos]
@@ -35,20 +35,6 @@ function M.setup(opts)
3535
return ""
3636
endfunction
3737
command! -bar -nargs=* -complete=custom,s:command_completion CompetiTest lua require("competitest.commands").command(<q-args>)
38-
39-
let s:old_commands = [
40-
\ ["Add", "add_testcase"],
41-
\ ["Edit", "edit_testcase"],
42-
\ ["Delete", "delete_testcase"],
43-
\ ["Convert", "convert"],
44-
\ ["Run", "run"],
45-
\ ["RunNC", "run_no_compile"],
46-
\ ["RunNE", "show_ui"],
47-
\ ["Receive", "receive"],
48-
\ ]
49-
for cmd in s:old_commands
50-
execute printf("command! -bar -nargs=* CompetiTest%s lua require('competitest.commands').deprecated_commands('%s', '%s', <q-args>)", cmd[0], cmd[0], cmd[1])
51-
endfor
5238
]])
5339

5440
-- create highlight groups

0 commit comments

Comments
 (0)