pub struct TrustFlagConfig {
pub enabled: bool,
pub flag_template: String,
pub value_template: String,
pub aliases: Vec<TrustFlagAlias>,
pub show_in_help: bool,
pub help_template: String,
}Expand description
Trust flag configuration
Allows framework users to define how trust flags are generated without the framework reserving specific flag names.
§Example
use sen_plugin_host::permission::{TrustFlagConfig, TrustEffect};
// Default: --trust-plugin=name, --trust-command=name
let config = TrustFlagConfig::default();
// Custom: --allow-plugin=name
let config = TrustFlagConfig::new()
.with_flag_template("--allow-{target}")
.with_alias("--yolo", TrustEffect::TrustAll);Fields§
§enabled: boolEnable trust flags feature
flag_template: StringFlag template: {target} is replaced with “plugin” or “command” Default: “–trust-{target}”
value_template: StringValue template: {name} is replaced with plugin/command name Default: “{name}”
aliases: Vec<TrustFlagAlias>Custom aliases for common trust patterns
show_in_help: boolWhether to show trust flags in help
help_template: StringHelp text template for generated flags
Implementations§
Source§impl TrustFlagConfig
impl TrustFlagConfig
Sourcepub fn with_flag_template(self, template: impl Into<String>) -> Self
pub fn with_flag_template(self, template: impl Into<String>) -> Self
Set the flag template
Variables:
{target}: “plugin” or “command”
Sourcepub fn with_value_template(self, template: impl Into<String>) -> Self
pub fn with_value_template(self, template: impl Into<String>) -> Self
Set the value template
Variables:
{name}: plugin or command name
Sourcepub fn with_alias(self, flag: impl Into<String>, effect: TrustEffect) -> Self
pub fn with_alias(self, flag: impl Into<String>, effect: TrustEffect) -> Self
Add a custom alias
Sourcepub fn with_alias_desc(
self,
flag: impl Into<String>,
description: impl Into<String>,
effect: TrustEffect,
) -> Self
pub fn with_alias_desc( self, flag: impl Into<String>, description: impl Into<String>, effect: TrustEffect, ) -> Self
Add a custom alias with description
Hide trust flags from help output
Sourcepub fn generate_flag(&self, target: TrustTarget) -> String
pub fn generate_flag(&self, target: TrustTarget) -> String
Generate the flag name for a target type
Sourcepub fn generate_value(&self, name: &str) -> String
pub fn generate_value(&self, name: &str) -> String
Generate the value format for a name
Sourcepub fn generate_help(&self, target: TrustTarget, name: &str) -> String
pub fn generate_help(&self, target: TrustTarget, name: &str) -> String
Generate help text for a flag
Sourcepub fn parse_args(&self, args: &[String]) -> TrustDirectives
pub fn parse_args(&self, args: &[String]) -> TrustDirectives
Parse command line arguments and extract trust directives
Trait Implementations§
Source§impl Clone for TrustFlagConfig
impl Clone for TrustFlagConfig
Source§fn clone(&self) -> TrustFlagConfig
fn clone(&self) -> TrustFlagConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TrustFlagConfig
impl Debug for TrustFlagConfig
Auto Trait Implementations§
impl Freeze for TrustFlagConfig
impl RefUnwindSafe for TrustFlagConfig
impl Send for TrustFlagConfig
impl Sync for TrustFlagConfig
impl Unpin for TrustFlagConfig
impl UnwindSafe for TrustFlagConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more