Skip to main content

schema_tree_from_clap

Function schema_tree_from_clap 

Source
pub fn schema_tree_from_clap(
    cmd: &Command,
    name: &str,
    description: &str,
    examples: impl IntoIterator<Item = (&'static str, &'static str)>,
) -> ToolSchema
Expand description

Build a recursive ToolSchema from a composed clap Command tree.

Like schema_from_clap for the top level, but also descends into cmd.get_subcommands(), so a subcommand-aware tool (kj context list …) reflects as a tree the kernel can walk with select_leaf to bind flags against the active leaf.

Each child’s name/description come from the clap subcommand itself (get_name/get_about) and its command-level aliases from get_all_aliases(). Examples belong to the top level only — clap doesn’t model per-subcommand usage examples. Flat tools (no get_subcommands()) produce a schema with empty subcommands, identical to schema_from_clap.