mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Add extern def which allows raw arguments (#8956)
# Description Extends the `extern` syntax to allow commands that accept raw arguments. This is mainly added to allow wrapper type scripts for external commands. This is an example on how this can be used: ```nushell extern foo [...rest] { print ($rest | str join ',' ) } foo --bar baz -- -q -u -x # => --bar,baz,--,-q,-u,-x ``` (It's only possible to accept a single ...varargs argument in the signature) # User-Facing Changes No breaking changes, just extra possibilities. # Tests + Formatting Added a test for this new behaviour and ran the toolkit pr checker # After Submitting This is advanced functionality but it should be documented, I will open a new PR on the book for that Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
This commit is contained in:
@ -141,3 +141,11 @@ fn def_with_paren_params() {
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extern_with_block() {
|
||||
let actual =
|
||||
nu!("extern foo [...rest] { print ($rest | str join ',' ) }; foo --bar baz -- -q -u -x");
|
||||
|
||||
assert_eq!(actual.out, "--bar,baz,--,-q,-u,-x");
|
||||
}
|
||||
|
Reference in New Issue
Block a user