[−][src]Struct nu_protocol::Signature
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: StringThe name of the command. Used when calling the command
usage: StringUsage instructions about the command
positional: Vec<(PositionalType, String)>The list of positional arguments, both required and optional, and their corresponding types and help text
rest_positional: Option<(SyntaxShape, String)>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)>The named flags with corresponding type and help text
yields: Option<Type>The type of values being sent out from the command into the pipeline, if any
input: Option<Type>The type of values being read in from the pipeline into the command, if any
is_filter: boolIf the command is expected to filter data, or to consume it (as a sink)
Implementations
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]
pub fn new(name: impl Into<String>) -> Signature[src]
Create a new command signature with the given name
pub fn build(name: impl Into<String>) -> Signature[src]
Create a new signature
pub fn desc(self, usage: impl Into<String>) -> Signature[src]
Add a description to the signature
pub fn required(
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature[src]
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
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]
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>
) -> Signature
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]
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
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]
self,
name: impl Into<String>,
ty: impl Into<SyntaxShape>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
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]
self,
name: impl Into<String>,
desc: impl Into<String>,
short: Option<char>
) -> Signature
Add a switch to the signature
pub fn filter(self) -> Signature[src]
Set the filter flag for the signature
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]
Add a type for the output of the command to the signature
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]
Get list of the short-hand flags
Trait Implementations
impl Clone for Signature[src]
impl Debug for Signature[src]
impl<'de> Deserialize<'de> for Signature[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PrettyDebugWithSource for Signature[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 Serialize 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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> PrettyDebugWithSource for T where
T: PrettyDebug, [src]
T: PrettyDebug,
fn pretty_debug(&self, _source: &str) -> DebugDocBuilder[src]
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<T> Serialize for T where
T: Serialize + ?Sized, [src]
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>[src]
impl<T> SpannedItem for T[src]
fn spanned(self, span: impl Into<Span>) -> Spanned<Self>[src]
fn spanned_unknown(self) -> Spanned<Self>[src]
impl<T> TaggedItem for T[src]
fn tagged(self, tag: impl Into<Tag>) -> Tagged<Self>[src]
fn tagged_unknown(self) -> Tagged<Self>[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,