Skip to main content

ScriptingToolSetBuilder

Struct ScriptingToolSetBuilder 

Source
pub struct ScriptingToolSetBuilder { /* private fields */ }
Expand description

Builder for ScriptingToolSet.

use bashkit_scripted_tool::{ScriptingToolSet, ToolArgs, ToolDef};

let toolset = ScriptingToolSet::builder("api")
    .short_description("Example API")
    .tool_fn(
        ToolDef::new("ping", "Ping a host"),
        |_args: &ToolArgs| Ok("pong\n".to_string()),
    )
    .build();

Implementations§

Source§

impl ScriptingToolSetBuilder

Source

pub fn locale(self, locale: &str) -> Self

Set locale for descriptions, help, prompts, and user-facing errors.

Source

pub fn short_description(self, desc: impl Into<String>) -> Self

One-line description for tool listings.

Source

pub fn tool(self, tool: ToolImpl) -> Self

Register a ToolImpl (definition + exec functions).

Source

pub fn tool_fn( self, def: ToolDef, exec: impl Fn(&ToolArgs) -> Result<String, String> + Send + Sync + 'static, ) -> Self

Register a tool with its definition and synchronous exec function.

Convenience shorthand — constructs a ToolImpl internally.

Source

pub fn async_tool_fn<F, Fut>(self, def: ToolDef, exec: F) -> Self
where F: Fn(ToolArgs) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<String, String>> + Send + 'static,

Register a tool with its definition and async exec function.

Convenience shorthand — constructs a ToolImpl internally.

Source

pub fn limits(self, limits: ExecutionLimits) -> Self

Set execution limits for the bash interpreter.

Source

pub fn profile(self, profile: ExecutionProfile) -> Self

Apply a coherent execution profile to the inner scripted tool.

Source

pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self

Add an environment variable visible inside scripts.

Source

pub fn with_discovery(self) -> Self

Switch to discovery mode: returns two tools from ScriptingToolSet::tools.

Source

pub fn build(&self) -> ScriptingToolSet

Build the ScriptingToolSet.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.