pub struct ActiveHelp {
pub message: String,
pub condition: Option<Arc<ConditionFn>>,
}Expand description
Represents an ActiveHelp message with optional condition
Fields§
§message: StringThe help message to display
condition: Option<Arc<ConditionFn>>Optional condition that must be true for this help to be shown
Implementations§
Source§impl ActiveHelp
impl ActiveHelp
Sourcepub fn new<S: Into<String>>(message: S) -> Self
pub fn new<S: Into<String>>(message: S) -> Self
Creates a new ActiveHelp message without condition
§Examples
use flag_rs::active_help::ActiveHelp;
let help = ActiveHelp::new("Use TAB to see available options");Sourcepub fn with_condition<S, F>(message: S, condition: F) -> Self
pub fn with_condition<S, F>(message: S, condition: F) -> Self
Creates a new ActiveHelp message with a condition
The help will only be shown when the condition returns true.
§Examples
use flag_rs::active_help::ActiveHelp;
let help = ActiveHelp::with_condition(
"Tip: Use -n <namespace> to filter results",
|ctx| ctx.flag("namespace").is_none()
);Sourcepub fn should_display(&self, ctx: &Context) -> bool
pub fn should_display(&self, ctx: &Context) -> bool
Checks if this help should be displayed given the current context
Trait Implementations§
Source§impl Clone for ActiveHelp
impl Clone for ActiveHelp
Auto Trait Implementations§
impl Freeze for ActiveHelp
impl !RefUnwindSafe for ActiveHelp
impl Send for ActiveHelp
impl Sync for ActiveHelp
impl Unpin for ActiveHelp
impl !UnwindSafe for ActiveHelp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more