mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 00:19:39 +01:00
c09a8a5ec9
# Description This PR adds a directory to the `$nu` constant that shows where the system level autoload directory is located at. This folder is modifiable at compile time with environment variables. ```rust // Create a system level directory for nushell scripts, modules, completions, etc // that can be changed by setting the NU_VENDOR_AUTOLOAD_DIR env var on any platform // before nushell is compiled OR if NU_VENDOR_AUTOLOAD_DIR is not set for non-windows // systems, the PREFIX env var can be set before compile and used as PREFIX/nushell/vendor/autoload // pseudo code // if env var NU_VENDOR_AUTOLOAD_DIR is set, in any platform, use it // if not, if windows, use ALLUSERPROFILE\nushell\vendor\autoload // if not, if non-windows, if env var PREFIX is set, use PREFIX/share/nushell/vendor/autoload // if not, use the default /usr/share/nushell/vendor/autoload ``` ### Windows default ```nushell ❯ $nu.vendor-autoload-dir C:\ProgramData\nushell\vendor\autoload ``` ### Non-Windows default ```nushell ❯ $nu.vendor-autoload-dir /usr/local/share/nushell/vendor/autoload ``` ### Non-Windows with PREFIX set ```nushell ❯ PREFIX=/usr/bob cargo r ❯ $nu.vendor-autoload-dir /usr/bob/share/nushell/vendor/autoload ``` ### Non-Windows with NU_VENDOR_AUTOLOAD_DIR set ```nushell ❯ NU_VENDOR_AUTOLOAD_DIR=/some/other/path/nushell/stuff cargo r ❯ $nu.vendor-autoload-dir /some/other/path/nushell/stuff ``` > [!IMPORTANT] To be clear, this PR does not do the auto-loading, it just sets up the folder to support that functionality that can be added in a later PR. The PR also does not create the folder defined. It's just setting the $nu constant. # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> |
||
---|---|---|
.. | ||
support | ||
mod.rs |