Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer: Send + Sync {
    // Required methods
    fn render_help(&self, command: &Command) -> String;
    fn render_markdown(&self, command: &Command) -> String;
    fn render_subcommand_list(&self, commands: &[Command]) -> String;
    fn render_ambiguity(&self, input: &str, candidates: &[String]) -> String;

    // Provided methods
    fn render_docs(&self, registry: &Registry) -> String { ... }
    fn render_skill_file(&self, command: &Command) -> String { ... }
    fn render_skill_files(&self, registry: &Registry) -> String { ... }
    fn render_skill_file_with_frontmatter(
        &self,
        cmd: &Command,
        frontmatter: &SkillFrontmatter,
    ) -> String { ... }
    fn render_skill_files_with_frontmatter_boxed(
        &self,
        registry: &Registry,
        frontmatter_fn: &dyn Fn(&Command) -> Option<SkillFrontmatter>,
    ) -> String { ... }
}
Expand description

A pluggable renderer for command help, Markdown docs, and disambiguation messages.

Implement this trait to fully customize how argot formats its output. Use crate::Cli::with_renderer to inject your implementation.

A DefaultRenderer is provided that delegates to the module-level free functions (render_help, render_markdown, etc.).

§Examples

struct UppercaseRenderer;

impl Renderer for UppercaseRenderer {
    fn render_help(&self, command: &Command) -> String {
        argot_cmd::render_help(command).to_uppercase()
    }
    fn render_markdown(&self, command: &Command) -> String {
        argot_cmd::render_markdown(command)
    }
    fn render_subcommand_list(&self, commands: &[Command]) -> String {
        argot_cmd::render_subcommand_list(commands)
    }
    fn render_ambiguity(&self, input: &str, candidates: &[String]) -> String {
        argot_cmd::render_ambiguity(input, candidates)
    }
}

Required Methods§

Source

fn render_help(&self, command: &Command) -> String

Render a plain-text help page for a command.

Source

fn render_markdown(&self, command: &Command) -> String

Render a Markdown documentation page for a command.

Source

fn render_subcommand_list(&self, commands: &[Command]) -> String

Render a compact listing of multiple commands.

Source

fn render_ambiguity(&self, input: &str, candidates: &[String]) -> String

Render a disambiguation message for an ambiguous command token.

Provided Methods§

Source

fn render_docs(&self, registry: &Registry) -> String

Render a full Markdown reference document for all commands in a registry.

Produces a # Commands heading, a table of contents with depth-based indentation, and per-command Markdown sections separated by ---.

Source

fn render_skill_file(&self, command: &Command) -> String

Render a structured Markdown skill file for a single command.

Skill files encode invariants, gotchas, best practices, anti-patterns, and examples in a format suitable for loading into an AI agent context (e.g. .claude/commands/). Sections with no content are omitted.

Source

fn render_skill_files(&self, registry: &Registry) -> String

Render skill files for all commands in a registry.

Calls render_skill_file on every command in depth-first order and concatenates the results separated by ---\n\n.

Source

fn render_skill_file_with_frontmatter( &self, cmd: &Command, frontmatter: &SkillFrontmatter, ) -> String

Render a skill file with YAML frontmatter prepended.

The default implementation delegates to render_skill_file_with_frontmatter.

Source

fn render_skill_files_with_frontmatter_boxed( &self, registry: &Registry, frontmatter_fn: &dyn Fn(&Command) -> Option<SkillFrontmatter>, ) -> String

Render all skill files in the registry, each optionally with frontmatter.

frontmatter_fn is called with each command; returning None falls back to plain skill file output for that command.

The default implementation delegates to render_skill_files_with_frontmatter.

Implementors§