pub struct Signature {
    pub name: String,
    pub usage: String,
    pub extra_usage: String,
    pub positional: Vec<(PositionalType, String)>,
    pub rest_positional: Option<(String, 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: String

The name of the command. Used when calling the command

usage: String

Usage instructions about the command

extra_usage: String

Longer or more verbose usage statement

positional: Vec<(PositionalType, String)>

The list of positional arguments, both required and optional, and their corresponding types and help text

rest_positional: Option<(String, 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

Create a new command signature with the given name

Create a new signature

Add a description to the signature

Add a required positional argument to the signature

Add an optional positional argument to the signature

Add an optional named flag argument to the signature

Add a required named flag argument to the signature

Add a switch to the signature

Set the filter flag for the signature

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

Add a type for the output of the command to the signature

Add a type for the input of the command to the signature

Get list of the short-hand flags

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Prepare a Signature for pretty-printing

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Performs the conversion.

Converts a value into a Spanned value

Converts a value into a Spanned value, using an unknown Span

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.