nushell/crates/nu-path/src
Piotr Kufel bcb7ef48b6
Reduce duplication in history path construction (#13475)
# Description
Currently there is a bit of chaos regarding construction of history file
paths. Various pieces of code across a number of crates reimplement the
same/similar logic:
- There is `get_history_path`, but it requires a directory parameter (it
really just joins it with a file name).
- Some places use a const for the directory parameter, others use a
string literal - in all cases the value seems to be `"nushell"`.
- Some places assume the `"nushell"` value, other plumb it down from
close to the top of the call stack.
- Some places use a constant for history file names while others assume
it.

This PR tries to make it so that the history/config path format is
defined in a single places and so dependencies on it are easier to
follow:
- It removes `get_history_path` and adds a `file_path` method to
`HistoryConfig` instead (an extra motivation being, this is a convenient
place that can be used from all creates that need a history file path)
- Adds a `nu_config_dir` function that returns the nushell configuration
directory.
- Updates existing code to rely on the above, effectively removing
duplicate uses of `"nushell"` and `NUSHELL_FOLDER` and assumptions about
file names associated with different history formats

# User-Facing Changes
None
2024-10-11 07:51:50 -05:00
..
assert_path_eq.rs Path expansion no longer removes trailing slashes (#12662) 2024-05-01 17:28:54 -05:00
components.rs Fix trailing slash in PWD set by cd (#12760) 2024-05-04 12:38:37 +03:00
dots.rs Expand multiple dots in path in completions (#13725) 2024-09-09 14:39:18 -04:00
expansions.rs Path migration part 3: $nu paths (#13368) 2024-08-01 10:16:31 +02:00
form.rs Edit path form doc comments (#13358) 2024-07-12 10:23:51 +02:00
helpers.rs Reduce duplication in history path construction (#13475) 2024-10-11 07:51:50 -05:00
lib.rs Reduce duplication in history path construction (#13475) 2024-10-11 07:51:50 -05:00
path.rs Clippy fixes from stable and nightly (#13455) 2024-07-31 20:37:40 +02:00
tilde.rs Clippy fixes from stable and nightly (#13455) 2024-07-31 20:37:40 +02:00
trailing_slash.rs Fix trailing slash in PWD set by cd (#12760) 2024-05-04 12:38:37 +03:00