A console command /name args: handler(args, ctx) gets the raw text after the name and
returns NULL, a character vector (printed) or list(prompt = "...") (sent as a prompt).
Usage
gptr_command(name, handler, description = NULL, complete = NULL)
Arguments
- name
Command name without the leading /.
- handler
function(args, ctx).
- description
One line for /help.
- complete
Optional function(prefix, ctx) returning completion candidates. Stored as
metadata for frontend integrations; the built-in console does not currently invoke it.
Value
A spec of class c("gptr_command", "gptr_spec").
Examples
gptr_command("rows", function(args, ctx) paste("rows:", nrow(mtcars)), description = "Show rows")
#> <gptr_command rows>
#> handler: <fn>
#> description: Show rows
#> api_version: 1.0