pub struct ParamSchema {
pub name: String,
pub param_type: String,
pub required: bool,
pub default: Option<Value>,
pub description: String,
pub aliases: Vec<String>,
pub consumes: usize,
}Expand description
Schema for a tool parameter.
Fields§
§name: StringParameter name.
param_type: StringType hint (string, int, bool, array, object, any).
required: boolWhether this parameter is required.
default: Option<Value>Default value if not required.
description: StringDescription for help text.
aliases: Vec<String>Alternative names/flags for this parameter (e.g., “-r”, “-R” for “recursive”).
consumes: usizeNumber of positional tokens this non-bool flag consumes per occurrence.
Default 1 (standard --flag value). Set to 2 for --flag NAME VALUE
patterns such as jq’s --arg / --argjson. When consumes > 1, the
kernel collects each occurrence as an inner array and accumulates
repeated occurrences under the same named key — the tool sees a
Value::Json(Array(Array(...))) listing every (N-tuple) occurrence.
Implementations§
Source§impl ParamSchema
impl ParamSchema
Sourcepub fn required(
name: impl Into<String>,
param_type: impl Into<String>,
description: impl Into<String>,
) -> ParamSchema
pub fn required( name: impl Into<String>, param_type: impl Into<String>, description: impl Into<String>, ) -> ParamSchema
Create a required parameter.
Sourcepub fn optional(
name: impl Into<String>,
param_type: impl Into<String>,
default: Value,
description: impl Into<String>,
) -> ParamSchema
pub fn optional( name: impl Into<String>, param_type: impl Into<String>, default: Value, description: impl Into<String>, ) -> ParamSchema
Create an optional parameter with a default value.
Sourcepub fn with_aliases(
self,
aliases: impl IntoIterator<Item = impl Into<String>>,
) -> ParamSchema
pub fn with_aliases( self, aliases: impl IntoIterator<Item = impl Into<String>>, ) -> ParamSchema
Add alternative names/flags for this parameter.
Aliases are used for short flags like -r, -R that map to recursive.
Sourcepub fn consumes(self, n: usize) -> ParamSchema
pub fn consumes(self, n: usize) -> ParamSchema
Declare how many positional tokens this non-bool flag consumes per
occurrence (--flag v1 v2 ...). Default is 1. Panics on 0 — a flag
that consumes nothing is a bool flag, not a schema-typed param.
Sourcepub fn matches_flag(&self, flag: &str) -> bool
pub fn matches_flag(&self, flag: &str) -> bool
Check if a flag name matches this parameter or any of its aliases.
Trait Implementations§
Source§impl Clone for ParamSchema
impl Clone for ParamSchema
Source§fn clone(&self) -> ParamSchema
fn clone(&self) -> ParamSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more