nushell/crates/nu-command/src/system
132ikl 06938659d2
Remove required positional arguments from run-external and exec (#14765)
# Description
This PR removes the required positional argument from `run-external` and
`exec` in favor of the rest arguments, meaning lists of external
commands can be spread directly into `run-external` and `exec`. This
does have the drawback of making calling `run-external` and `exec` with
no arguments a run-time error rather than a parse error, but I don't
imagine that is an issue.

Before (for both `run-external` and `exec`):
```nushell
run-external
# => Error: nu::parser::missing_positional
# => 
# =>   × Missing required positional argument.
# =>    ╭─[entry #9:1:13]
# =>  1 │ run-external
# =>    ╰────
# =>   help: Usage: run-external <command> ...(args) . Use `--help` for more
# =>         information.

let command = ["cat" "hello.txt"]
run-external ...$command
# => Error: nu::parser::missing_positional
# => 
# =>   × Missing required positional argument.
# =>    ╭─[entry #11:1:14]
# =>  1 │ run-external ...$command
# =>    ·              ▲
# =>    ·              ╰── missing command
# =>    ╰────
# =>   help: Usage: run-external <command> ...(args) . Use `--help` for more
# =>         information.
run-external ($command | first) ...($command | skip 1)
# => hello world!
```

After (for both `run-external` and `exec`):
```nushell
run-external
# => Error: nu:🐚:missing_parameter
# => 
# =>   × Missing parameter: no command given.
# =>    ╭─[entry #2:1:1]
# =>  1 │ run-external
# =>    · ──────┬─────
# =>    ·       ╰── missing parameter: no command given
# =>    ╰────
# => 

let command = ["cat" "hello.txt"]
run-external ...$command
# => hello world!
```



# User-Facing Changes
Lists can now be spread directly into `run-external` and `exec`:

```nushell
let command = [cat hello.txt]
run-external ...$command
# => hello world!
``` 

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
N/A
2025-01-16 06:10:28 +08:00
..
sys Add --long flag for sys cpu (#14485) 2024-12-01 05:56:42 -06:00
complete.rs Fix try not working with let, etc. (#13885) 2024-09-23 06:44:25 -05:00
exec.rs Remove required positional arguments from run-external and exec (#14765) 2025-01-16 06:10:28 +08:00
mod.rs Remove required positional arguments from run-external and exec (#14765) 2025-01-16 06:10:28 +08:00
nu_check.rs Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
ps.rs add start_time to ps -l on macos (#14127) 2024-10-21 11:55:30 -05:00
registry_query.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
run_external.rs Remove required positional arguments from run-external and exec (#14765) 2025-01-16 06:10:28 +08:00
uname.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
which_.rs Add "whereis" and "get-command" to which search terms (#14797) 2025-01-10 17:55:41 -06:00