Expand description
Central execution context for click-rs.
The Context struct holds state relevant for script execution at every level.
It manages parameter values, parent-child relationships, and provides access to
shared metadata and resources.
§Thread-Local Context Stack
Click uses a thread-local stack to provide implicit access to the current context.
Use push_context, pop_context, and get_current_context to manage this stack.
§Example
use click::context::{Context, ContextBuilder, push_context, pop_context, get_current_context};
use std::sync::Arc;
let ctx = ContextBuilder::new()
.info_name("myapp")
.build();
let ctx = Arc::new(ctx);
push_context(Arc::clone(&ctx));
assert!(get_current_context().is_some());
pop_context();
assert!(get_current_context().is_none());Structs§
- Context
- The central execution context for click-rs.
- Context
Builder - Builder for creating
Contextinstances with custom settings.
Functions§
- get_
current_ context - Get the current context from the thread-local stack.
- pop_
context - Pop and return the top context from the thread-local context stack.
- push_
context - Push a context onto the thread-local context stack.
Type Aliases§
- Boxed
Value - Type alias for shared values that can be stored in context maps. Uses Arc to allow cloning and sharing across parent-child contexts.
- Help
Renderer - A pluggable help renderer that can be installed into a context.