Struct nu_protocol::Signature [−][src]
pub struct Signature {
pub name: String,
pub usage: String,
pub positional: Vec<(PositionalType, String)>,
pub rest_positional: Option<(SyntaxShape, String)>,
pub named: IndexMap<String, (NamedType, String)>,
pub yields: Option<Type>,
pub input: Option<Type>,
pub is_filter: bool,
}Expand description
The full signature of a command. All commands have a signature similar to a function signature. Commands will use this information to register themselves with Nu’s core engine so that the command can be invoked, help can be displayed, and calls to the command can be error-checked.
Fields
name: StringExpand description
The name of the command. Used when calling the command
usage: StringExpand description
Usage instructions about the command
positional: Vec<(PositionalType, String)>Expand description
The list of positional arguments, both required and optional, and their corresponding types and help text
rest_positional: Option<(SyntaxShape, String)>Expand description
After the positional arguments, a catch-all for the rest of the arguments that might follow, their type, and help text
named: IndexMap<String, (NamedType, String)>Expand description
The named flags with corresponding type and help text
yields: Option<Type>Expand description
The type of values being sent out from the command into the pipeline, if any
input: Option<Type>Expand description
The type of values being read in from the pipeline into the command, if any
is_filter: boolExpand description
If the command is expected to filter data, or to consume it (as a sink)
Implementations
impl Signature[src]
impl Signature[src]pub fn shift_positional(&mut self)[src]
pub fn remove_named(&mut self, name: &str)[src]
pub fn allowed(&self) -> Vec<String>[src]
impl Signature[src]
impl Signature[src]pub fn new(name: impl Into<String>) -> Signature[src]
pub fn new(name: impl Into<String>) -> Signature[src]Create a new command signature with the given name
pub fn required(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature[src]
pub fn required(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature[src]Add a required positional argument to the signature
pub fn optional(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature[src]
pub fn optional(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature[src]Add an optional positional argument to the signature
pub fn named(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]
pub fn named(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]Add an optional named flag argument to the signature
pub fn required_named(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]
pub fn required_named(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]Add a required named flag argument to the signature
pub fn switch(
self,
name: impl Into<String>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]
pub fn switch(
self,
name: impl Into<String>,
desc: impl Into<String>,
short: Option<char>
) -> Signature[src]Add a switch to the signature
pub fn rest(self, ty: SyntaxShape, desc: impl Into<String>) -> Signature[src]
pub fn rest(self, ty: SyntaxShape, desc: impl Into<String>) -> Signature[src]Set the type for the “rest” of the positional arguments Note: Not naming the field in your struct holding the rest values “rest”, can cause errors when deserializing
pub fn yields(self, ty: Type) -> Signature[src]
pub fn yields(self, ty: Type) -> Signature[src]Add a type for the output of the command to the signature
pub fn input(self, ty: Type) -> Signature[src]
pub fn input(self, ty: Type) -> Signature[src]Add a type for the input of the command to the signature
pub fn get_shorts(&self) -> Vec<char>[src]
pub fn get_shorts(&self) -> Vec<char>[src]Get list of the short-hand flags
Trait Implementations
impl<'de> Deserialize<'de> for Signature[src]
impl<'de> Deserialize<'de> for Signature[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]Deserialize this value from the given Serde deserializer. Read more
impl PrettyDebugWithSource for Signature[src]
impl PrettyDebugWithSource for Signature[src]fn pretty_debug(&self, source: &str) -> DebugDocBuilder[src]
fn pretty_debug(&self, source: &str) -> DebugDocBuilder[src]Prepare a Signature for pretty-printing
fn refined_pretty_debug(
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder[src]
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
fn debug(&self, source: impl Into<Text>) -> String where
Self: Clone, [src]
Self: Clone,
fn debuggable(self, source: impl Into<Text>) -> DebuggableWithSource<Self>[src]
impl Eq for Signature[src]
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
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]pub fn equivalent(&self, key: &K) -> bool[src]
pub fn equivalent(&self, key: &K) -> bool[src]Compare self to key and return true if they are equal.
impl<T> SpannedItem for T[src]
impl<T> SpannedItem for T[src]impl<T> TaggedItem for T[src]
impl<T> TaggedItem for T[src]impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,