nushell/crates
YizhePKU bdb6daa4b5
Migrate to a new PWD API (#12603)
This is the first PR towards migrating to a new `$env.PWD` API that
returns potentially un-canonicalized paths. Refer to PR #12515 for
motivations.

## New API: `EngineState::cwd()`

The goal of the new API is to cover both parse-time and runtime use
case, and avoid unintentional misuse. It takes an `Option<Stack>` as
argument, which if supplied, will search for `$env.PWD` on the stack in
additional to the engine state. I think with this design, there's less
confusion over parse-time and runtime environments. If you have access
to a stack, just supply it; otherwise supply `None`.

## Deprecation of other PWD-related APIs

Other APIs are re-implemented using `EngineState::cwd()` and properly
documented. They're marked deprecated, but their behavior is unchanged.
Unused APIs are deleted, and code that accesses `$env.PWD` directly
without using an API is rewritten.

Deprecated APIs:

* `EngineState::current_work_dir()`
* `StateWorkingSet::get_cwd()`
* `env::current_dir()`
* `env::current_dir_str()`
* `env::current_dir_const()`
* `env::current_dir_str_const()`

Other changes:

* `EngineState::get_cwd()` (deleted)
* `StateWorkingSet::list_env()` (deleted)
* `repl::do_run_cmd()` (rewritten with `env::current_dir_str()`)

## `cd` and `pwd` now use logical paths by default

This pulls the changes from PR #12515. It's currently somewhat broken
because using non-canonicalized paths exposed a bug in our path
normalization logic (Issue #12602). Once that is fixed, this should
work.

## Future plans

This PR needs some tests. Which test helpers should I use, and where
should I put those tests?

I noticed that unquoted paths are expanded within `eval_filepath()` and
`eval_directory()` before they even reach the `cd` command. This means
every paths is expanded twice. Is this intended?

Once this PR lands, the plan is to review all usages of the deprecated
APIs and migrate them to `EngineState::cwd()`. In the meantime, these
usages are annotated with `#[allow(deprecated)]` to avoid breaking CI.

---------

Co-authored-by: Jakub Žádník <kubouch@gmail.com>
2024-05-03 14:33:09 +03:00
..
nu_plugin_custom_values Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_example Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_formats Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_gstat Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_inc Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_nu_example Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_polars Fix clippy::wrong_self_convention in polars plugin (#12737) 2024-05-02 19:31:51 +02:00
nu_plugin_python Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_query Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_stress_internals Upgrade to interprocess 2.0.0 (#12729) 2024-05-02 22:31:33 -07:00
nu-cli Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-cmd-base Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-cmd-dataframe Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-cmd-extra Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-cmd-lang Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
nu-cmd-plugin Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-color-config Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
nu-command Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-engine Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-explore Eliminate dead code in nu-explore (#12735) 2024-05-03 08:36:58 +08:00
nu-glob Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-json Rework for new clippy lints (#12736) 2024-05-02 19:29:03 +02:00
nu-lsp Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-parser Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-path Path expansion no longer removes trailing slashes (#12662) 2024-05-01 17:28:54 -05:00
nu-plugin Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
nu-plugin-core Upgrade to interprocess 2.0.0 (#12729) 2024-05-02 22:31:33 -07:00
nu-plugin-engine Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-plugin-protocol Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
nu-plugin-test-support Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
nu-pretty-hex Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-protocol Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-std Migrate to a new PWD API (#12603) 2024-05-03 14:33:09 +03:00
nu-system Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-table Rework for new clippy lints (#12736) 2024-05-02 19:29:03 +02:00
nu-term-grid Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-test-support Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-utils overhaul shell_integration to enable individual control over ansi escape sequences (#12629) 2024-05-02 09:56:50 -04:00
nuon add support for cell-paths to NUON (#12718) 2024-05-03 09:25:19 +08:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.