Add type signature example for def command (#13561)

# Description

By popular demand (a.k.a.
https://github.com/nushell/nushell.github.io/issues/1035), provide an
example of a type signature in the `def` help.

# User-Facing Changes

Help/Doc

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib

# After Submitting

N/A
This commit is contained in:
NotTheDr01ds 2024-08-06 22:40:30 -04:00 committed by GitHub
parent bc6947cd09
commit c18e6bfca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -70,6 +70,11 @@ impl Command for Def {
example: r#"def --wrapped my-echo [...rest] { ^echo ...$rest }; my-echo -e 'spam\tspam'"#, example: r#"def --wrapped my-echo [...rest] { ^echo ...$rest }; my-echo -e 'spam\tspam'"#,
result: Some(Value::test_string("spam\tspam")), result: Some(Value::test_string("spam\tspam")),
}, },
Example {
description: "Define a custom command with a type signature. Passing a non-int value will result in an error",
example: r#"def only_int []: int -> int { $in }; 42 | only_int"#,
result: Some(Value::test_int(42)),
},
] ]
} }
} }