Snodo.Prompt.Simple (snodo v0.2.0)

Copy Markdown View Source

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
end

argument/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:

Summary

Functions

Declares one prompt argument. Arguments are listed in declaration order.

Functions

argument(name, opts \\ [])

(macro)

Declares one prompt argument. Arguments are listed in declaration order.