Struct nu_protocol::Signature [−][src]
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
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 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
Trait Implementations
fn 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
Prepare a Signature for pretty-printing
fn refined_pretty_debug(
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
Auto Trait Implementations
impl RefUnwindSafe for Signature
impl UnwindSafe for Signature
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.