Command signature

nu commands can be given explicit signatures; take str stats as an example, the signature is like this:

def "str stats" []: string -> record { }

The type names between the : and the opening curly brace { describe the command's input/output pipeline types. The input type for a given pipeline, in this case string, is given before the ->; and the output type record is given after ->. There can be multiple input/output types. If there are multiple input/output types, they can be placed within brackets and separated with commas, as in str join:

def "str join" [separator?: string]: [list -> string, string -> string] { }

It says that the str join command takes an optional string type argument, and an input pipeline of either a list (implying list<any>) with output type of string, or a single string, again with output type of string.

Some commands don't accept or require data through the input pipeline, thus the input type will be <nothing>. The same is true for the output type if the command returns null (e.g. rm or hide):

def hide [module: string, members?]: nothing -> nothing { }