Skip to content

Commit

Permalink
feat: better handle invalid actions (jackMort#362)
Browse files Browse the repository at this point in the history
Whenever the user inputs a invalid action, indicate the action does not
exist, and show a list of the available actions.
  • Loading branch information
joninvski authored Jan 26, 2024
1 parent 589961b commit 65ca1e3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lua/chatgpt/flows/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ function M.run_action(opts)
local action_name = opts.fargs[1]
local item = ACTIONS[action_name]

if item == nil then
if action_name == nil then
vim.notify("You need to specify an action", vim.log.levels.WARN)
else
vim.notify('Invalid input: "' .. action_name .. '"\n', vim.log.levels.WARN)
end

-- show the available valid actions
local keys = {}
for k, _ in pairs(ACTIONS) do
table.insert(keys, k)
end
local s = table.concat(keys, ", ")

vim.notify("Valid actions are: " .. s, vim.log.levels.WARN)

return
end

-- parse args
--
if item.args then
Expand Down

0 comments on commit 65ca1e3

Please sign in to comment.