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,
}

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: String

The name of the command. Used when calling the command

usage: String

Usage 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: bool

If 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]

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]

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]

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]

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]

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]

impl Eq for Signature[src]

impl PartialEq<Signature> for Signature[src]

impl PrettyDebugWithSource for Signature[src]

fn pretty_debug(&self, source: &str) -> DebugDocBuilder[src]

Prepare a Signature for pretty-printing

impl Serialize for Signature[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SpannedItem for T[src]

impl<T> TaggedItem for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.