pub struct Signature {Show 14 fields
pub name: String,
pub description: String,
pub extra_description: String,
pub search_terms: Vec<String>,
pub required_positional: Vec<PositionalArg>,
pub optional_positional: Vec<PositionalArg>,
pub rest_positional: Option<PositionalArg>,
pub named: Vec<Flag>,
pub input_output_types: Vec<(Type, Type)>,
pub allow_variants_without_examples: bool,
pub is_filter: bool,
pub creates_scope: bool,
pub allows_unknown_args: bool,
pub category: Category,
}
Expand description
Signature information of a Command
Fields§
§name: String
§description: String
§extra_description: String
§search_terms: Vec<String>
§required_positional: Vec<PositionalArg>
§optional_positional: Vec<PositionalArg>
§rest_positional: Option<PositionalArg>
§named: Vec<Flag>
§input_output_types: Vec<(Type, Type)>
§allow_variants_without_examples: bool
§is_filter: bool
§creates_scope: bool
§allows_unknown_args: bool
§category: Category
Implementations§
Source§impl Signature
impl Signature
pub fn new(name: impl Into<String>) -> Signature
pub fn get_input_type(&self) -> Type
pub fn get_output_type(&self) -> Type
pub fn add_help(self) -> Signature
pub fn build(name: impl Into<String>) -> Signature
Sourcepub fn description(self, msg: impl Into<String>) -> Signature
pub fn description(self, msg: impl Into<String>) -> Signature
Add a description to the signature
This should be a single sentence as it is the part shown for example in the completion menu.
Sourcepub fn extra_description(self, msg: impl Into<String>) -> Signature
pub fn extra_description(self, msg: impl Into<String>) -> Signature
Add an extra description to the signature.
Here additional documentation can be added
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 allows_unknown_args(self) -> Signature
pub fn allows_unknown_args(self) -> Signature
Allow unknown signature parameters
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_output_type(self, input_type: Type, output_type: Type) -> Signature
pub fn input_output_type(self, input_type: Type, output_type: Type) -> Signature
Changes the input type of the command 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
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
pub fn formatted_flags(self) -> String
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 Freeze for Signature
impl !RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl !UnwindSafe for Signature
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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 moreSource§impl<T> IntoSpanned for T
impl<T> IntoSpanned for T
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§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 moreSource§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