Prompt.Router.Usage (prompt v0.12.0)

View Source

Generates usage text for routers and commands from their specs.

Inside each section of a command's usage, Arguments and Options separately, every label is padded to the longest label of that section plus 4 spaces.

Summary

Functions

Usage text for one command. path is the list of command words typed after the app name, for example ["import"] or ["categories", "add"]; the fallback command passes []. A command with subcommands lists them under Commands:, and a group (no module) shows <command> in its usage line.

The @moduledoc text of module, or nil when docs are not available.

Usage text for a router: its top-level commands with the first line of each command module's moduledoc, when docs are available.

Functions

command(app, path, command_spec)

@spec command(atom() | nil, [String.t()], Prompt.Router.CommandSpec.t()) :: String.t()

Usage text for one command. path is the list of command words typed after the app name, for example ["import"] or ["categories", "add"]; the fallback command passes []. A command with subcommands lists them under Commands:, and a group (no module) shows <command> in its usage line.

moduledoc(module)

@spec moduledoc(module() | nil) :: String.t() | nil

The @moduledoc text of module, or nil when docs are not available.

router(app, specs)

@spec router(atom() | nil, [Prompt.Router.CommandSpec.t()]) :: String.t()

Usage text for a router: its top-level commands with the first line of each command module's moduledoc, when docs are available.