File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -1231,10 +1231,10 @@ function M.get_slash_commands()
12311231 table.insert (result , {
12321232 slash_cmd = ' /' .. name ,
12331233 desc = def .description or ' User command' ,
1234- fn = function ()
1235- M .run_user_command (name , {} )
1234+ fn = function (... )
1235+ M .run_user_command (name , ... )
12361236 end ,
1237- args = false ,
1237+ args = config_file . command_takes_arguments ( def ) ,
12381238 })
12391239 end
12401240 end
Original file line number Diff line number Diff line change @@ -126,4 +126,11 @@ function M.get_mcp_servers()
126126 return cfg and cfg .mcp or nil
127127end
128128
129+ --- Does this opencode user command take arguments?
130+ --- @param command OpencodeCommand
131+ --- @return boolean
132+ function M .command_takes_arguments (command )
133+ return command .template and command .template :find (' $ARGUMENTS' ) ~= nil or false
134+ end
135+
129136return M
Original file line number Diff line number Diff line change @@ -404,7 +404,7 @@ describe('opencode.api', function()
404404 config_file .get_user_commands = function ()
405405 return {
406406 [' build' ] = { description = ' Build the project' },
407- [' test' ] = { description = ' Run tests' },
407+ [' test' ] = { description = ' Run tests' , template = ' Run tests with $ARGUMENTS ' },
408408 }
409409 end
410410
@@ -423,7 +423,7 @@ describe('opencode.api', function()
423423 test_found = true
424424 assert .equal (' Run tests' , cmd .desc )
425425 assert .is_function (cmd .fn )
426- assert .falsy (cmd .args )
426+ assert .truthy (cmd .args )
427427 end
428428 end
429429
You can’t perform that action at this time.
0 commit comments