Struct nu_protocol::Signature
source · pub struct Signature {Show 16 fields
pub name: String,
pub usage: String,
pub extra_usage: String,
pub search_terms: Vec<String>,
pub required_positional: Vec<PositionalArg>,
pub optional_positional: Vec<PositionalArg>,
pub rest_positional: Option<PositionalArg>,
pub vectorizes_over_list: bool,
pub named: Vec<Flag>,
pub input_type: Type,
pub output_type: Type,
pub input_output_types: Vec<(Type, Type)>,
pub allow_variants_without_examples: bool,
pub is_filter: bool,
pub creates_scope: bool,
pub category: Category,
}Fields§
§name: String§usage: String§extra_usage: String§search_terms: Vec<String>§required_positional: Vec<PositionalArg>§optional_positional: Vec<PositionalArg>§rest_positional: Option<PositionalArg>§vectorizes_over_list: bool§named: Vec<Flag>§input_type: Type§output_type: Type§input_output_types: Vec<(Type, Type)>§allow_variants_without_examples: bool§is_filter: bool§creates_scope: bool§category: CategoryImplementations§
source§impl Signature
impl Signature
pub fn new(name: impl Into<String>) -> Signature
pub fn add_help(self) -> Signature
pub fn build(name: impl Into<String>) -> Signature
sourcepub fn extra_usage(self, msg: impl Into<String>) -> Signature
pub fn extra_usage(self, msg: impl Into<String>) -> Signature
Add an extra description to the signature
sourcepub fn search_terms(self, terms: Vec<String>) -> Signature
pub fn search_terms(self, terms: Vec<String>) -> Signature
Add search terms to the signature
sourcepub fn update_from_command(self, command: &dyn Command) -> Signature
pub fn update_from_command(self, command: &dyn Command) -> Signature
Update signature’s fields from a Command trait implementation
sourcepub fn required(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
pub fn required(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
Add a required positional argument to the signature
sourcepub fn optional(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
pub fn optional(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
Add an optional positional argument to the signature
pub fn rest(
self,
name: &str,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
sourcepub fn operates_on_cell_paths(&self) -> bool
pub fn operates_on_cell_paths(&self) -> bool
Is this command capable of operating on its input via cell paths?
sourcepub fn named(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
pub fn named(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
Add an optional named flag argument to the signature
sourcepub fn required_named(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
pub fn required_named(
self,
name: impl Into<String>,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
Add a required named flag argument to the signature
sourcepub fn switch(
self,
name: impl Into<String>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
pub fn switch(
self,
name: impl Into<String>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
Add a switch to the signature
sourcepub fn input_type(self, input_type: Type) -> Signature
pub fn input_type(self, input_type: Type) -> Signature
Changes the input type of the command signature
sourcepub fn output_type(self, output_type: Type) -> Signature
pub fn output_type(self, output_type: Type) -> Signature
Changes the output type of the command signature
pub fn vectorizes_over_list(self, vectorizes_over_list: bool) -> Signature
sourcepub fn input_output_types(
self,
input_output_types: Vec<(Type, Type)>
) -> Signature
pub fn input_output_types(
self,
input_output_types: Vec<(Type, Type)>
) -> Signature
Set the input-output type signature variants of the command
sourcepub fn creates_scope(self) -> Signature
pub fn creates_scope(self) -> Signature
Sets that signature will create a scope as it parses
pub fn allow_variants_without_examples(self, allow: bool) -> Signature
pub fn call_signature(&self) -> String
sourcepub fn get_shorts(&self) -> Vec<char> ⓘ
pub fn get_shorts(&self) -> Vec<char> ⓘ
Get list of the short-hand flags
pub fn get_positional(&self, position: usize) -> Option<PositionalArg>
pub fn num_positionals(&self) -> usize
pub fn num_positionals_after(&self, idx: usize) -> usize
sourcepub fn get_long_flag(&self, name: &str) -> Option<Flag>
pub fn get_long_flag(&self, name: &str) -> Option<Flag>
Find the matching long flag
sourcepub fn get_short_flag(&self, short: char) -> Option<Flag>
pub fn get_short_flag(&self, short: char) -> Option<Flag>
Find the matching long flag
sourcepub fn predeclare(self) -> Box<dyn Command>
pub fn predeclare(self) -> Box<dyn Command>
Create a placeholder implementation of Command as a way to predeclare a definition’s signature so other definitions can see it. This placeholder is later replaced with the full definition in a second pass of the parser.
sourcepub fn into_block_command(self, block_id: BlockId) -> Box<dyn Command>
pub fn into_block_command(self, block_id: BlockId) -> Box<dyn Command>
Combines a signature and a block into a runnable block
Trait Implementations§
source§impl<'de> Deserialize<'de> for Signature
impl<'de> Deserialize<'de> for Signature
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Signature
Auto Trait Implementations§
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more