nushell/crates/nu-protocol/src/config
Douglas 8c1ab7e0a3
Add proper config defaults for hooks (#14341)
# Release Notes Excerpt

* Hooks now default to an empty value of the proper type (e.g., `[]` or
`{}`) when not otherwise specified

# Description

```nushell
# Start with no config
nu -n
# Populate with defaults
$env.config = {}
$env.config.hooks
```

* Before: All hooks other than `display_output` were set to `null`.
Attempting to append a hook using `++=` would fail unless it had already
been assigned.
* After:
* `pre_prompt`, `pre_execution`, and `command_not_found` are set to
empty lists. This allows the user to simply append new hooks using
`++=`.
* `env_change` is set to an empty record. This allows the user to add
new hooks using `merge`, although a "helper" command would still be
useful (TODO: stdlib).

Also fixed a typo in an error message.

# User-Facing Changes

There shouldn't be any breaking changes since (before) there were no
guarantees of the hook's value/type. Previously, users would have to
check for `null` and `default` to an empty list before appending. Any
user-strategies for dealing with the problem should continue to work
after this change.

# Tests + Formatting

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

Note that, for reasons I cannot ascertain, this PR appears to have
*fixed* the `command_not_found_error_recognizes_non_executable_file`
test that was previously broken by #12953. That PR essentially rewrote
the test to match the new behavior, but it no longer tested what it was
intended to test.

Now, the test is working again as designed (and as it works in the
REPL).

# After Submitting

This will be covered in the Configuration update for #14249. This PR
will simplify several examples in the doc.
2024-11-14 20:27:26 -08:00
..
completions.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
datetime_format.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
display_errors.rs change display_error.exit_code to false (#13873) 2024-10-14 09:57:30 -05:00
error.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
filesize.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
helper.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
history.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
hooks.rs Add proper config defaults for hooks (#14341) 2024-11-14 20:27:26 -08:00
ls.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
mod.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
output.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
plugin_gc.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
prelude.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
reedline.rs add name to $env.config.keybindings (#14159) 2024-10-23 19:23:41 +02:00
rm.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
shell_integration.rs Refactor config updates (#13802) 2024-10-11 18:40:32 +02:00
table.rs Introduce footer_inheritance option (#14070) 2024-10-23 19:45:47 +02:00