Skip to main content

spec_driven_docs/commands/
hooks.rs

1//! `hooks` subcommand: runtime-shape.
2//!
3//! Renders the registry in the requested style to stdout. What the render
4//! contains is the renderer's business; this handler only projects the
5//! flags.
6
7use crate::cli::hooks::HooksArgs;
8use crate::context::AppContext;
9use crate::error::AppError;
10use crate::output;
11use crate::services::hooks_render::{RenderOptions, Style, render_block, render_gates};
12
13/// Render the delivered gate set.
14///
15/// # Errors
16///
17/// None; rendering is pure.
18pub fn run(_ctx: &AppContext, args: HooksArgs) -> Result<(), AppError> {
19    let options = RenderOptions {
20        style: args.style,
21        docs_root: args.docs_root,
22        entry: args.entry,
23        language: args.language,
24        indent: args.indent,
25    };
26    let rendered = match options.style {
27        Style::Block => render_block(&options),
28        Style::Manifest => render_gates(&options),
29    };
30    output::line(rendered.trim_end_matches('\n'));
31    Ok(())
32}