Snodo.Prompt with declared arguments and plain return values from render/2.
Arguments are declared one per line instead of as a list of maps:
defmodule Review do
use Snodo.Prompt.Simple, name: "review", description: "Review a package"
argument "name", required: true, description: "Package name on hex.pm"
argument "focus", description: "quality, security, or upgrade"
@impl true
def render(%{"name" => name} = arguments, _context) do
{:ok, "Review #{name}, focusing on #{arguments["focus"] || "quality"}."}
end
endargument/2 accepts :required, :description, and :title. The module
accepts every other Snodo.Prompt option (:name, :title, :description,
:completion_arguments, :icons, :metadata) and its definition is
validated at compile time by the same checks use Snodo.Prompt runs.
render/2 may return:
{:ok, text}with a binary: one user message containing that text.{:ok, message}or{:ok, [message]}: messages built withSnodo.Prompt.message/2, validated by the router as usual.{:ok, %Snodo.Result{}}and{:error, reason}, unchanged. UseSnodo.Result.prompt_get/2for a description or metadata andSnodo.Result.input_required/1for MRTR.
Summary
Functions
Declares one prompt argument. Arguments are listed in declaration order.