Struct nu_protocol::Signature
source · [−]pub struct Signature {
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 named: Vec<Flag>,
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>
named: Vec<Flag>
is_filter: bool
creates_scope: bool
category: Category
Implementations
sourceimpl Signature
impl Signature
pub fn new(name: impl Into<String>) -> 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 a required positional argument to the signature
pub fn rest(
self,
name: &str,
shape: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
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 creates_scope(self) -> Signature
pub fn creates_scope(self) -> Signature
Sets that signature will create a scope as it parses
pub fn call_signature(&self) -> String
sourcepub fn get_shorts(&self) -> Vec<char>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_shorts(&self) -> Vec<char>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get list of the short-hand flags
sourcepub fn get_names(&self) -> Vec<&str>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_names(&self) -> Vec<&str>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get list of the long-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
sourceimpl<'de> Deserialize<'de> for Signature
impl<'de> Deserialize<'de> for Signature
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more