attr example for core
Attribute for adding examples to custom commands.
Signature
> attr example {flags} (description) (example)
Flags
-
--result {any}: Expected output of example.
Parameters
-
description: Description of the example. -
example: Example code snippet.
Input/output types:
| input | output |
|---|---|
| nothing | record<description: string, example: string> |
Examples
Add examples to custom command.
> # Double numbers
@example "double an int" { 2 | double } --result 4
@example "double a float" { 0.25 | double } --result 0.5
def double []: [number -> number] { $in * 2 }
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/attr_example.html