2019-05-10 16:59:12 +00:00
|
|
|
[package]
|
2022-03-13 18:30:27 +00:00
|
|
|
authors = ["The Nushell Project Developers"]
|
2023-05-20 12:57:51 +00:00
|
|
|
build = "scripts/build.rs"
|
2020-07-05 20:12:44 +00:00
|
|
|
default-run = "nu"
|
2020-04-06 07:16:14 +00:00
|
|
|
description = "A new type of shell"
|
2020-07-05 20:12:44 +00:00
|
|
|
documentation = "https://www.nushell.sh/book/"
|
2023-01-05 12:24:42 +00:00
|
|
|
edition = "2021"
|
2020-07-05 20:12:44 +00:00
|
|
|
exclude = ["images"]
|
|
|
|
homepage = "https://www.nushell.sh"
|
|
|
|
license = "MIT"
|
|
|
|
name = "nu"
|
2019-07-16 19:17:46 +00:00
|
|
|
repository = "https://github.com/nushell/nushell"
|
2024-07-31 16:14:50 +00:00
|
|
|
rust-version = "1.78.0"
|
2024-08-22 09:36:32 +00:00
|
|
|
version = "0.97.2"
|
2021-06-30 01:42:56 +00:00
|
|
|
|
|
|
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
|
2022-11-23 16:46:06 +00:00
|
|
|
[package.metadata.binstall]
|
|
|
|
pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.{ archive-format }"
|
|
|
|
pkg-fmt = "tgz"
|
|
|
|
|
|
|
|
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
|
|
|
|
pkg-fmt = "zip"
|
|
|
|
|
2021-08-25 19:29:36 +00:00
|
|
|
[workspace]
|
2021-10-28 06:12:33 +00:00
|
|
|
members = [
|
2024-03-07 22:40:31 +00:00
|
|
|
"crates/nu-cli",
|
|
|
|
"crates/nu-engine",
|
|
|
|
"crates/nu-parser",
|
|
|
|
"crates/nu-system",
|
|
|
|
"crates/nu-cmd-base",
|
|
|
|
"crates/nu-cmd-extra",
|
|
|
|
"crates/nu-cmd-lang",
|
2024-04-21 12:36:26 +00:00
|
|
|
"crates/nu-cmd-plugin",
|
2024-03-07 22:40:31 +00:00
|
|
|
"crates/nu-command",
|
|
|
|
"crates/nu-color-config",
|
|
|
|
"crates/nu-explore",
|
|
|
|
"crates/nu-json",
|
|
|
|
"crates/nu-lsp",
|
|
|
|
"crates/nu-pretty-hex",
|
|
|
|
"crates/nu-protocol",
|
Add derive macros for `FromValue` and `IntoValue` to ease the use of `Value`s in Rust code (#13031)
# Description
After discussing with @sholderbach the cumbersome usage of
`nu_protocol::Value` in Rust, I created a derive macro to simplify it.
I’ve added a new crate called `nu-derive-value`, which includes two
macros, `IntoValue` and `FromValue`. These are re-exported in
`nu-protocol` and should be encouraged to be used via that re-export.
The macros ensure that all types can easily convert from and into
`Value`. For example, as a plugin author, you can define your plugin
configuration using a Rust struct and easily convert it using
`FromValue`. This makes plugin configuration less of a hassle.
I introduced the `IntoValue` trait for a standardized approach to
converting values into `Value` (and a fallible variant `TryIntoValue`).
This trait could potentially replace existing `into_value` methods.
Along with this, I've implemented `FromValue` for several standard types
and refined other implementations to use blanket implementations where
applicable.
I made these design choices with input from @devyn.
There are more improvements possible, but this is a solid start and the
PR is already quite substantial.
# User-Facing Changes
For `nu-protocol` users, these changes simplify the handling of
`Value`s. There are no changes for end-users of nushell itself.
# Tests + Formatting
Documenting the macros itself is not really possible, as they cannot
really reference any other types since they are the root of the
dependency graph. The standard library has the same problem
([std::Debug](https://doc.rust-lang.org/stable/std/fmt/derive.Debug.html)).
However I documented the `FromValue` and `IntoValue` traits completely.
For testing, I made of use `proc-macro2` in the derive macro code. This
would allow testing the generated source code. Instead I just tested
that the derived functionality is correct. This is done in
`nu_protocol::value::test_derive`, as a consumer of `nu-derive-value`
needs to do the testing of the macro usage. I think that these tests
should provide a stable baseline so that users can be sure that the impl
works.
# After Submitting
With these macros available, we can probably use them in some examples
for plugins to showcase the use of them.
2024-06-17 23:05:11 +00:00
|
|
|
"crates/nu-derive-value",
|
2024-03-07 22:40:31 +00:00
|
|
|
"crates/nu-plugin",
|
2024-04-27 17:08:12 +00:00
|
|
|
"crates/nu-plugin-core",
|
|
|
|
"crates/nu-plugin-engine",
|
|
|
|
"crates/nu-plugin-protocol",
|
2024-03-23 18:29:54 +00:00
|
|
|
"crates/nu-plugin-test-support",
|
2024-03-07 22:40:31 +00:00
|
|
|
"crates/nu_plugin_inc",
|
|
|
|
"crates/nu_plugin_gstat",
|
|
|
|
"crates/nu_plugin_example",
|
|
|
|
"crates/nu_plugin_query",
|
|
|
|
"crates/nu_plugin_custom_values",
|
|
|
|
"crates/nu_plugin_formats",
|
2024-04-10 00:31:43 +00:00
|
|
|
"crates/nu_plugin_polars",
|
Local socket mode and foreground terminal control for plugins (#12448)
# Description
Adds support for running plugins using local socket communication
instead of stdio. This will be an optional thing that not all plugins
have to support.
This frees up stdio for use to make plugins that use stdio to create
terminal UIs, cc @amtoine, @fdncred.
This uses the [`interprocess`](https://crates.io/crates/interprocess)
crate (298 stars, MIT license, actively maintained), which seems to be
the best option for cross-platform local socket support in Rust. On
Windows, a local socket name is provided. On Unixes, it's a path. The
socket name is kept to a relatively small size because some operating
systems have pretty strict limits on the whole path (~100 chars), so on
macOS for example we prefer `/tmp/nu.{pid}.{hash64}.sock` where the hash
includes the plugin filename and timestamp to be unique enough.
This also adds an API for moving plugins in and out of the foreground
group, which is relevant for Unixes where direct terminal control
depends on that.
TODO:
- [x] Generate local socket path according to OS conventions
- [x] Add support for passing `--local-socket` to the plugin executable
instead of `--stdio`, and communicating over that instead
- [x] Test plugins that were broken, including
[amtoine/nu_plugin_explore](https://github.com/amtoine/nu_plugin_explore)
- [x] Automatically upgrade to using local sockets when supported,
falling back if it doesn't work, transparently to the user without any
visible error messages
- Added protocol feature: `LocalSocket`
- [x] Reset preferred mode to `None` on `register`
- [x] Allow plugins to detect whether they're running on a local socket
and can use stdio freely, so that TUI plugins can just produce an error
message otherwise
- Implemented via `EngineInterface::is_using_stdio()`
- [x] Clean up foreground state when plugin command exits on the engine
side too, not just whole plugin
- [x] Make sure tests for failure cases work as intended
- `nu_plugin_stress_internals` added
# User-Facing Changes
- TUI plugins work
- Non-Rust plugins could optionally choose to use this
- This might behave differently, so will need to test it carefully
across different operating systems
# Tests + Formatting
- :green_circle: `toolkit fmt`
- :green_circle: `toolkit clippy`
- :green_circle: `toolkit test`
- :green_circle: `toolkit test stdlib`
# After Submitting
- [ ] Document local socket option in plugin contrib docs
- [ ] Document how to do a terminal UI plugin in plugin contrib docs
- [ ] Document: `EnterForeground` engine call
- [ ] Document: `LeaveForeground` engine call
- [ ] Document: `LocalSocket` protocol feature
2024-04-15 18:28:18 +00:00
|
|
|
"crates/nu_plugin_stress_internals",
|
2024-03-07 22:40:31 +00:00
|
|
|
"crates/nu-std",
|
|
|
|
"crates/nu-table",
|
|
|
|
"crates/nu-term-grid",
|
|
|
|
"crates/nu-test-support",
|
|
|
|
"crates/nu-utils",
|
create `nuon` crate from `from nuon` and `to nuon` (#12553)
# Description
playing with the NUON format in Rust code in some plugins, we agreed
with the team it was a great time to create a standalone NUON format to
allow Rust devs to use this Nushell file format.
> **Note**
> this PR almost copy-pastes the code from
`nu_commands/src/formats/from/nuon.rs` and
`nu_commands/src/formats/to/nuon.rs` to `nuon/src/from.rs` and
`nuon/src/to.rs`, with minor tweaks to make then standalone functions,
e.g. remove the rest of the command implementations
### TODO
- [x] add tests
- [x] add documentation
# User-Facing Changes
devs will have access to a new crate, `nuon`, and two functions,
`from_nuon` and `to_nuon`
```rust
from_nuon(
input: &str,
span: Option<Span>,
) -> Result<Value, ShellError>
```
```rust
to_nuon(
input: &Value,
raw: bool,
tabs: Option<usize>,
indent: Option<usize>,
span: Option<Span>,
) -> Result<String, ShellError>
```
# Tests + Formatting
i've basically taken all the tests from
`crates/nu-command/tests/format_conversions/nuon.rs` and converted them
to use `from_nuon` and `to_nuon` instead of Nushell commands
- i've created a `nuon_end_to_end` to run both conversions with an
optional middle value to check that all is fine
> **Note**
> the `nuon::tests::read_code_should_fail_rather_than_panic` test does
give different results locally and in the CI...
> i've left it ignored with comments to help future us :)
# After Submitting
mention that in the release notes for sure!!
2024-04-19 11:54:16 +00:00
|
|
|
"crates/nuon",
|
2021-10-28 06:12:33 +00:00
|
|
|
]
|
2021-08-25 19:29:36 +00:00
|
|
|
|
2024-03-07 22:40:31 +00:00
|
|
|
[workspace.dependencies]
|
2024-03-23 23:46:02 +00:00
|
|
|
alphanumeric-sort = "1.5"
|
|
|
|
ansi-str = "0.8"
|
`explore`: adopt `anyhow`, support `CustomValue`, remove help system (#12692)
This PR:
1. Adds basic support for `CustomValue` to `explore`. Previously `open
foo.db | explore` didn't really work, now we "materialize" the whole
database to a `Value` before loading it
2. Adopts `anyhow` for error handling in `explore`. Previously we were
kind of rolling our own version of `anyhow` by shoving all errors into a
`std::io::Error`; I think this is much nicer. This was necessary because
as part of 1), collecting input is now fallible...
3. Removes a lot of `explore`'s fancy command help system.
- Previously each command (`:help`, `:try`, etc.) had a sophisticated
help system with examples etc... but this was not very visible to users.
You had to know to run `:help :try` or view a list of commands with
`:help :`
- As discussed previously, we eventually want to move to a less modal
approach for `explore`, without the Vim-like commands. And so I don't
think it's worth keeping this command help system around (it's
intertwined with other stuff, and making these changes would have been
harder if keeping it).
4. Rename the `--reverse` flag to `--tail`. The flag scrolls to the end
of the data, which IMO is described better by "tail"
5. Does some renaming+commenting to clear up things I found difficult to
understand when navigating the `explore` code
I initially thought 1) would be just a few lines, and then this PR blew
up into much more extensive changes 😅
## Before
The whole database was being displayed as a single Nuon/JSON line 🤔
![image](https://github.com/nushell/nushell/assets/26268125/6383f43b-fdff-48b4-9604-398438ad1499)
## After
The database gets displayed like a record
![image](https://github.com/nushell/nushell/assets/26268125/2f00ed7b-a3c4-47f4-a08c-98d07efc7bb4)
## Future work
It is sort of annoying that we have to load a whole SQLite database into
memory to make this work; it will be impractical for large databases.
I'd like to explore improvements to `CustomValue` that can make this
work more efficiently.
2024-05-01 22:34:37 +00:00
|
|
|
anyhow = "1.0.82"
|
2024-05-04 15:16:40 +00:00
|
|
|
base64 = "0.22.1"
|
2024-03-23 23:46:02 +00:00
|
|
|
bracoxide = "0.1.2"
|
2024-04-21 12:36:26 +00:00
|
|
|
brotli = "5.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
byteorder = "1.5"
|
Improve working with `IntoValue` and `FromValue` for byte collections (#13641)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx
you can also mention related issues, PRs or discussions!
-->
# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.
Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
I was working with byte collections like `Vec<u8>` and
[`bytes::Bytes`](https://docs.rs/bytes/1.7.1/bytes/struct.Bytes.html),
both are currently not possible to be used directly in a struct that
derives `IntoValue` and `FromValue` at the same time. The `Vec<u8>` will
convert itself into a `Value::List` but expects a `Value::String` or
`Value::Binary` to load from. I now also implemented that it can load
from `Value::List` just like the other `Vec<uX>` versions. For further
working with byte collections the type `bytes::Bytes` is wildly used,
therefore I added a implementation for it. `bytes` is already part of
the dependency graph as many crates (more than 5000 to crates.io) use
it.
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
User of `nu-protocol` as library, e.g. plugin developers, can now use
byte collections more easily in their data structures and derive
`IntoValue` and `FromValue` for it.
# 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
> ```
-->
I added a few tests that check that these byte collections are correctly
translated in and from `Value`. They live in `test_derive.rs` as part of
the `ByteContainer` and I also explicitely tested that `FromValue` for
`Vec<u8>` works as expected.
- :green_circle: `toolkit fmt`
- :green_circle: `toolkit clippy`
- :green_circle: `toolkit test`
- :green_circle: `toolkit test stdlib`
# 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.
-->
Maybe it should be explored if `Value::Binary` should use `bytes::Bytes`
instead of `Vec<u8>`.
2024-08-22 22:59:00 +00:00
|
|
|
bytes = "1"
|
2024-03-23 23:46:02 +00:00
|
|
|
bytesize = "1.3"
|
|
|
|
calamine = "0.24.0"
|
|
|
|
chardetng = "0.1.17"
|
2024-05-04 18:16:20 +00:00
|
|
|
chrono = { default-features = false, version = "0.4.34" }
|
2024-03-23 23:46:02 +00:00
|
|
|
chrono-humanize = "0.2.3"
|
|
|
|
chrono-tz = "0.8"
|
|
|
|
crossbeam-channel = "0.5.8"
|
2024-09-06 14:57:45 +00:00
|
|
|
crossterm = "0.28.1"
|
2024-03-23 23:46:02 +00:00
|
|
|
csv = "1.3"
|
2024-03-07 22:40:31 +00:00
|
|
|
ctrlc = "3.4"
|
2024-03-23 23:46:02 +00:00
|
|
|
dialoguer = { default-features = false, version = "0.11" }
|
|
|
|
digest = { default-features = false, version = "0.10" }
|
2024-07-16 12:16:26 +00:00
|
|
|
dirs = "5.0"
|
2024-07-19 10:47:07 +00:00
|
|
|
dirs-sys = "0.4"
|
2024-03-23 23:46:02 +00:00
|
|
|
dtparse = "2.0"
|
|
|
|
encoding_rs = "0.8"
|
2024-03-07 22:40:31 +00:00
|
|
|
fancy-regex = "0.13"
|
2024-03-23 23:46:02 +00:00
|
|
|
filesize = "0.2"
|
|
|
|
filetime = "0.2"
|
|
|
|
fuzzy-matcher = "0.3"
|
|
|
|
heck = "0.5.0"
|
|
|
|
human-date-parser = "0.1.1"
|
2024-09-04 02:02:01 +00:00
|
|
|
indexmap = "2.5"
|
2024-03-23 23:46:02 +00:00
|
|
|
indicatif = "0.17"
|
2024-06-20 08:10:27 +00:00
|
|
|
interprocess = "2.2.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
is_executable = "1.0"
|
Bump itertools from 0.12.1 to 0.13.0 (#13774)
Bumps [itertools](https://github.com/rust-itertools/itertools) from
0.12.1 to 0.13.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md">itertools's
changelog</a>.</em></p>
<blockquote>
<h2>0.13.0</h2>
<h3>Breaking</h3>
<ul>
<li>Removed implementation of <code>DoubleEndedIterator</code> for
<code>ConsTuples</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/853">#853</a>)</li>
<li>Made <code>MultiProduct</code> fused and fixed on an empty iterator
(<a
href="https://redirect.github.com/rust-itertools/itertools/issues/835">#835</a>,
<a
href="https://redirect.github.com/rust-itertools/itertools/issues/834">#834</a>)</li>
<li>Changed <code>iproduct!</code> to return tuples for maxi one
iterator too (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/870">#870</a>)</li>
<li>Changed <code>PutBack::put_back</code> to return the old value (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/880">#880</a>)</li>
<li>Removed deprecated <code>repeat_call, Itertools::{foreach, step,
map_results, fold_results}</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/878">#878</a>)</li>
<li>Removed <code>TakeWhileInclusive::new</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/912">#912</a>)</li>
</ul>
<h3>Added</h3>
<ul>
<li>Added <code>Itertools::{smallest_by, smallest_by_key, largest,
largest_by, largest_by_key}</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/654">#654</a>,
<a
href="https://redirect.github.com/rust-itertools/itertools/issues/885">#885</a>)</li>
<li>Added <code>Itertools::tail</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/899">#899</a>)</li>
<li>Implemented <code>DoubleEndedIterator</code> for
<code>ProcessResults</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/910">#910</a>)</li>
<li>Implemented <code>Debug</code> for <code>FormatWith</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/931">#931</a>)</li>
<li>Added <code>Itertools::get</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/891">#891</a>)</li>
</ul>
<h3>Changed</h3>
<ul>
<li>Deprecated <code>Itertools::group_by</code> (renamed
<code>chunk_by</code>) (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/866">#866</a>,
<a
href="https://redirect.github.com/rust-itertools/itertools/issues/879">#879</a>)</li>
<li>Deprecated <code>unfold</code> (use <code>std::iter::from_fn</code>
instead) (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/871">#871</a>)</li>
<li>Optimized <code>GroupingMapBy</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/873">#873</a>,
<a
href="https://redirect.github.com/rust-itertools/itertools/issues/876">#876</a>)</li>
<li>Relaxed <code>Fn</code> bounds to <code>FnMut</code> in
<code>diff_with, Itertools::into_group_map_by</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/886">#886</a>)</li>
<li>Relaxed <code>Debug/Clone</code> bounds for <code>MapInto</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/889">#889</a>)</li>
<li>Documented the <code>use_alloc</code> feature (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/887">#887</a>)</li>
<li>Optimized <code>Itertools::set_from</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/888">#888</a>)</li>
<li>Removed badges in <code>README.md</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/890">#890</a>)</li>
<li>Added "no-std" categories in <code>Cargo.toml</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/894">#894</a>)</li>
<li>Fixed <code>Itertools::k_smallest</code> on short unfused iterators
(<a
href="https://redirect.github.com/rust-itertools/itertools/issues/900">#900</a>)</li>
<li>Deprecated <code>Itertools::tree_fold1</code> (renamed
<code>tree_reduce</code>) (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/895">#895</a>)</li>
<li>Deprecated <code>GroupingMap::fold_first</code> (renamed
<code>reduce</code>) (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/902">#902</a>)</li>
<li>Fixed <code>Itertools::k_smallest(0)</code> to consume the iterator,
optimized <code>Itertools::k_smallest(1)</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/909">#909</a>)</li>
<li>Specialized <code>Combinations::nth</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/914">#914</a>)</li>
<li>Specialized <code>MergeBy::fold</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/920">#920</a>)</li>
<li>Specialized <code>CombinationsWithReplacement::nth</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/923">#923</a>)</li>
<li>Specialized <code>FlattenOk::{fold, rfold}</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/927">#927</a>)</li>
<li>Specialized <code>Powerset::nth</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/924">#924</a>)</li>
<li>Documentation fixes (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/882">#882</a>,
<a
href="https://redirect.github.com/rust-itertools/itertools/issues/936">#936</a>)</li>
<li>Fixed <code>assert_equal</code> for iterators longer than
<code>i32::MAX</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/932">#932</a>)</li>
<li>Updated the <code>must_use</code> message of non-lazy
<code>KMergeBy</code> and <code>TupleCombinations</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/939">#939</a>)</li>
</ul>
<h3>Notable Internal Changes</h3>
<ul>
<li>Tested iterator laziness (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/792">#792</a>)</li>
<li>Created <code>CONTRIBUTING.md</code> (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/767">#767</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/rust-itertools/itertools/commit/d5084d15e959b85d89a49e5cd33ad6267bc541a3"><code>d5084d1</code></a>
Prepare v0.13.0 release (<a
href="https://redirect.github.com/rust-itertools/itertools/issues/937">#937</a>)</li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/d7c99d55daeaa76f482444e95beb99f5744ced4e"><code>d7c99d5</code></a>
<code>TupleCombinations</code> is not lazy but must be used
nonetheless</li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/074c7fcc07c2bfd60f238585c05134ea3eb43f77"><code>074c7fc</code></a>
<code>KMergeBy</code> is not lazy but must be used nonetheless</li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/2ad9e07ae860bb891e48b35edfea5b3286dcb4ab"><code>2ad9e07</code></a>
<code>assert_equal</code>: fix
<code>clippy::default_numeric_fallback</code></li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/0d4efc84323399b47b09ae9da1ff3fdfc2cf95e1"><code>0d4efc8</code></a>
Remove free function <code>get</code></li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/05cc0ee256e84d665e34209053ebc62ef7e4463d"><code>05cc0ee</code></a>
<code>get(s..=usize::MAX)</code> should be fine when <code>s !=
0</code></li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/3c16f14baa5515376adcd8c530f6d3d275b14f44"><code>3c16f14</code></a>
<code>get</code>: when is it ESI and/or DEI</li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/4dd6ba0e7c44bb287dff1098d8fb6ab77c32bf87"><code>4dd6ba0</code></a>
<code>get</code>: panics if the range includes
<code>usize::MAX</code></li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/7a9ce56fc59489668178d696db76afb3580a359c"><code>7a9ce56</code></a>
<code>get(r: Range)</code> as <code>Skip\<Take></code></li>
<li><a
href="https://github.com/rust-itertools/itertools/commit/f676f2f96451220c827c62f714d79ce6454d0184"><code>f676f2f</code></a>
Remove the unspecified check about
<code>.get(exhausted_range_inclusive)</code></li>
<li>Additional commits viewable in <a
href="https://github.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0">compare
view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=itertools&package-manager=cargo&previous-version=0.12.1&new-version=0.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-04 02:02:48 +00:00
|
|
|
itertools = "0.13"
|
2024-03-23 23:46:02 +00:00
|
|
|
libc = "0.2"
|
|
|
|
libproc = "0.14"
|
2024-03-07 22:40:31 +00:00
|
|
|
log = "0.4"
|
2024-03-23 23:46:02 +00:00
|
|
|
lru = "0.12"
|
|
|
|
lscolors = { version = "0.17", default-features = false }
|
|
|
|
lsp-server = "0.7.5"
|
|
|
|
lsp-types = "0.95.0"
|
|
|
|
mach2 = "0.4"
|
2024-04-12 20:56:40 +00:00
|
|
|
md5 = { version = "0.10", package = "md-5" }
|
2024-03-13 01:35:40 +00:00
|
|
|
miette = "7.2"
|
2024-08-13 19:27:28 +00:00
|
|
|
mime = "0.3.17"
|
2024-03-23 23:46:02 +00:00
|
|
|
mime_guess = "2.0"
|
2024-08-07 03:09:23 +00:00
|
|
|
mockito = { version = "1.5", default-features = false }
|
2024-08-06 20:28:38 +00:00
|
|
|
multipart-rs = "0.1.11"
|
2024-03-23 23:46:02 +00:00
|
|
|
native-tls = "0.2"
|
2024-09-04 02:03:02 +00:00
|
|
|
nix = { version = "0.29", default-features = false }
|
2024-03-23 23:46:02 +00:00
|
|
|
notify-debouncer-full = { version = "0.3", default-features = false }
|
2024-07-23 22:54:54 +00:00
|
|
|
nu-ansi-term = "0.50.1"
|
2024-03-23 23:46:02 +00:00
|
|
|
num-format = "0.4"
|
|
|
|
num-traits = "0.2"
|
|
|
|
omnipath = "0.1"
|
2024-03-07 22:40:31 +00:00
|
|
|
once_cell = "1.18"
|
2024-07-17 01:47:17 +00:00
|
|
|
open = "5.3"
|
2024-06-07 00:08:02 +00:00
|
|
|
os_pipe = { version = "1.2", features = ["io_safety"] }
|
2024-03-07 22:40:31 +00:00
|
|
|
pathdiff = "0.2"
|
|
|
|
percent-encoding = "2"
|
2024-04-26 11:23:16 +00:00
|
|
|
pretty_assertions = "1.4"
|
2024-03-23 23:46:02 +00:00
|
|
|
print-positions = "0.6"
|
Add derive macros for `FromValue` and `IntoValue` to ease the use of `Value`s in Rust code (#13031)
# Description
After discussing with @sholderbach the cumbersome usage of
`nu_protocol::Value` in Rust, I created a derive macro to simplify it.
I’ve added a new crate called `nu-derive-value`, which includes two
macros, `IntoValue` and `FromValue`. These are re-exported in
`nu-protocol` and should be encouraged to be used via that re-export.
The macros ensure that all types can easily convert from and into
`Value`. For example, as a plugin author, you can define your plugin
configuration using a Rust struct and easily convert it using
`FromValue`. This makes plugin configuration less of a hassle.
I introduced the `IntoValue` trait for a standardized approach to
converting values into `Value` (and a fallible variant `TryIntoValue`).
This trait could potentially replace existing `into_value` methods.
Along with this, I've implemented `FromValue` for several standard types
and refined other implementations to use blanket implementations where
applicable.
I made these design choices with input from @devyn.
There are more improvements possible, but this is a solid start and the
PR is already quite substantial.
# User-Facing Changes
For `nu-protocol` users, these changes simplify the handling of
`Value`s. There are no changes for end-users of nushell itself.
# Tests + Formatting
Documenting the macros itself is not really possible, as they cannot
really reference any other types since they are the root of the
dependency graph. The standard library has the same problem
([std::Debug](https://doc.rust-lang.org/stable/std/fmt/derive.Debug.html)).
However I documented the `FromValue` and `IntoValue` traits completely.
For testing, I made of use `proc-macro2` in the derive macro code. This
would allow testing the generated source code. Instead I just tested
that the derived functionality is correct. This is done in
`nu_protocol::value::test_derive`, as a consumer of `nu-derive-value`
needs to do the testing of the macro usage. I think that these tests
should provide a stable baseline so that users can be sure that the impl
works.
# After Submitting
With these macros available, we can probably use them in some examples
for plugins to showcase the use of them.
2024-06-17 23:05:11 +00:00
|
|
|
proc-macro-error = { version = "1.0", default-features = false }
|
|
|
|
proc-macro2 = "1.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
procfs = "0.16.0"
|
|
|
|
pwd = "1.3"
|
2024-08-07 01:16:03 +00:00
|
|
|
quick-xml = "0.32.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
quickcheck = "1.0"
|
|
|
|
quickcheck_macros = "1.0"
|
Add derive macros for `FromValue` and `IntoValue` to ease the use of `Value`s in Rust code (#13031)
# Description
After discussing with @sholderbach the cumbersome usage of
`nu_protocol::Value` in Rust, I created a derive macro to simplify it.
I’ve added a new crate called `nu-derive-value`, which includes two
macros, `IntoValue` and `FromValue`. These are re-exported in
`nu-protocol` and should be encouraged to be used via that re-export.
The macros ensure that all types can easily convert from and into
`Value`. For example, as a plugin author, you can define your plugin
configuration using a Rust struct and easily convert it using
`FromValue`. This makes plugin configuration less of a hassle.
I introduced the `IntoValue` trait for a standardized approach to
converting values into `Value` (and a fallible variant `TryIntoValue`).
This trait could potentially replace existing `into_value` methods.
Along with this, I've implemented `FromValue` for several standard types
and refined other implementations to use blanket implementations where
applicable.
I made these design choices with input from @devyn.
There are more improvements possible, but this is a solid start and the
PR is already quite substantial.
# User-Facing Changes
For `nu-protocol` users, these changes simplify the handling of
`Value`s. There are no changes for end-users of nushell itself.
# Tests + Formatting
Documenting the macros itself is not really possible, as they cannot
really reference any other types since they are the root of the
dependency graph. The standard library has the same problem
([std::Debug](https://doc.rust-lang.org/stable/std/fmt/derive.Debug.html)).
However I documented the `FromValue` and `IntoValue` traits completely.
For testing, I made of use `proc-macro2` in the derive macro code. This
would allow testing the generated source code. Instead I just tested
that the derived functionality is correct. This is done in
`nu_protocol::value::test_derive`, as a consumer of `nu-derive-value`
needs to do the testing of the macro usage. I think that these tests
should provide a stable baseline so that users can be sure that the impl
works.
# After Submitting
With these macros available, we can probably use them in some examples
for plugins to showcase the use of them.
2024-06-17 23:05:11 +00:00
|
|
|
quote = "1.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
rand = "0.8"
|
2024-08-23 16:18:51 +00:00
|
|
|
rand_chacha = "0.3.1"
|
2024-03-23 23:46:02 +00:00
|
|
|
ratatui = "0.26"
|
2024-03-27 06:44:17 +00:00
|
|
|
rayon = "1.10"
|
2024-08-20 23:28:19 +00:00
|
|
|
reedline = "0.34.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
regex = "1.9.5"
|
2024-04-26 11:23:16 +00:00
|
|
|
rmp = "0.8"
|
2024-05-02 00:26:00 +00:00
|
|
|
rmp-serde = "1.3"
|
2024-03-23 23:46:02 +00:00
|
|
|
ropey = "1.6.1"
|
|
|
|
roxmltree = "0.19"
|
2024-03-07 22:40:31 +00:00
|
|
|
rstest = { version = "0.18", default-features = false }
|
2024-03-23 23:46:02 +00:00
|
|
|
rusqlite = "0.31"
|
2024-07-17 01:47:09 +00:00
|
|
|
rust-embed = "8.5.0"
|
2024-09-05 22:57:36 +00:00
|
|
|
serde = { version = "1.0" }
|
2024-03-07 22:40:31 +00:00
|
|
|
serde_json = "1.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
serde_urlencoded = "0.7.1"
|
|
|
|
serde_yaml = "0.9"
|
|
|
|
sha2 = "0.10"
|
|
|
|
strip-ansi-escapes = "0.2.0"
|
Add derive macros for `FromValue` and `IntoValue` to ease the use of `Value`s in Rust code (#13031)
# Description
After discussing with @sholderbach the cumbersome usage of
`nu_protocol::Value` in Rust, I created a derive macro to simplify it.
I’ve added a new crate called `nu-derive-value`, which includes two
macros, `IntoValue` and `FromValue`. These are re-exported in
`nu-protocol` and should be encouraged to be used via that re-export.
The macros ensure that all types can easily convert from and into
`Value`. For example, as a plugin author, you can define your plugin
configuration using a Rust struct and easily convert it using
`FromValue`. This makes plugin configuration less of a hassle.
I introduced the `IntoValue` trait for a standardized approach to
converting values into `Value` (and a fallible variant `TryIntoValue`).
This trait could potentially replace existing `into_value` methods.
Along with this, I've implemented `FromValue` for several standard types
and refined other implementations to use blanket implementations where
applicable.
I made these design choices with input from @devyn.
There are more improvements possible, but this is a solid start and the
PR is already quite substantial.
# User-Facing Changes
For `nu-protocol` users, these changes simplify the handling of
`Value`s. There are no changes for end-users of nushell itself.
# Tests + Formatting
Documenting the macros itself is not really possible, as they cannot
really reference any other types since they are the root of the
dependency graph. The standard library has the same problem
([std::Debug](https://doc.rust-lang.org/stable/std/fmt/derive.Debug.html)).
However I documented the `FromValue` and `IntoValue` traits completely.
For testing, I made of use `proc-macro2` in the derive macro code. This
would allow testing the generated source code. Instead I just tested
that the derived functionality is correct. This is done in
`nu_protocol::value::test_derive`, as a consumer of `nu-derive-value`
needs to do the testing of the macro usage. I think that these tests
should provide a stable baseline so that users can be sure that the impl
works.
# After Submitting
With these macros available, we can probably use them in some examples
for plugins to showcase the use of them.
2024-06-17 23:05:11 +00:00
|
|
|
syn = "2.0"
|
2024-03-07 22:40:31 +00:00
|
|
|
sysinfo = "0.30"
|
2024-08-23 22:35:42 +00:00
|
|
|
tabled = { version = "0.16.0", default-features = false }
|
2024-03-07 22:40:31 +00:00
|
|
|
tempfile = "3.10"
|
2024-03-23 23:46:02 +00:00
|
|
|
terminal_size = "0.3"
|
|
|
|
titlecase = "2.0"
|
|
|
|
toml = "0.8"
|
|
|
|
trash = "3.3"
|
|
|
|
umask = "2.1"
|
2024-03-07 22:40:31 +00:00
|
|
|
unicode-segmentation = "1.11"
|
2024-03-23 23:46:02 +00:00
|
|
|
unicode-width = "0.1"
|
2024-07-11 14:08:42 +00:00
|
|
|
ureq = { version = "2.10", default-features = false }
|
2024-03-23 23:46:02 +00:00
|
|
|
url = "2.2"
|
2024-07-03 11:49:18 +00:00
|
|
|
uu_cp = "0.0.27"
|
|
|
|
uu_mkdir = "0.0.27"
|
|
|
|
uu_mktemp = "0.0.27"
|
|
|
|
uu_mv = "0.0.27"
|
|
|
|
uu_whoami = "0.0.27"
|
|
|
|
uu_uname = "0.0.27"
|
|
|
|
uucore = "0.0.27"
|
2024-07-17 01:46:59 +00:00
|
|
|
uuid = "1.10.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
v_htmlescape = "0.15.0"
|
|
|
|
wax = "0.6"
|
2024-03-07 22:40:31 +00:00
|
|
|
which = "6.0.0"
|
2024-03-23 23:46:02 +00:00
|
|
|
windows = "0.54"
|
2024-07-19 10:47:07 +00:00
|
|
|
windows-sys = "0.48"
|
2024-03-23 23:46:02 +00:00
|
|
|
winreg = "0.52"
|
2024-03-07 22:40:31 +00:00
|
|
|
|
2024-08-28 21:37:17 +00:00
|
|
|
[workspace.lints.clippy]
|
|
|
|
# Warning: workspace lints affect library code as well as tests, so don't enable lints that would be too noisy in tests like that.
|
|
|
|
# todo = "warn"
|
|
|
|
unchecked_duration_subtraction = "warn"
|
|
|
|
|
|
|
|
[lints]
|
|
|
|
workspace = true
|
|
|
|
|
2021-06-30 01:42:56 +00:00
|
|
|
[dependencies]
|
2024-08-22 09:36:32 +00:00
|
|
|
nu-cli = { path = "./crates/nu-cli", version = "0.97.2" }
|
|
|
|
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.97.2" }
|
|
|
|
nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.97.2" }
|
|
|
|
nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.97.2", optional = true }
|
|
|
|
nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.97.2" }
|
|
|
|
nu-command = { path = "./crates/nu-command", version = "0.97.2" }
|
|
|
|
nu-engine = { path = "./crates/nu-engine", version = "0.97.2" }
|
|
|
|
nu-explore = { path = "./crates/nu-explore", version = "0.97.2" }
|
|
|
|
nu-lsp = { path = "./crates/nu-lsp/", version = "0.97.2" }
|
|
|
|
nu-parser = { path = "./crates/nu-parser", version = "0.97.2" }
|
|
|
|
nu-path = { path = "./crates/nu-path", version = "0.97.2" }
|
|
|
|
nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.97.2" }
|
|
|
|
nu-protocol = { path = "./crates/nu-protocol", version = "0.97.2" }
|
|
|
|
nu-std = { path = "./crates/nu-std", version = "0.97.2" }
|
|
|
|
nu-system = { path = "./crates/nu-system", version = "0.97.2" }
|
|
|
|
nu-utils = { path = "./crates/nu-utils", version = "0.97.2" }
|
2024-03-07 22:40:31 +00:00
|
|
|
reedline = { workspace = true, features = ["bashisms", "sqlite"] }
|
2022-09-19 14:28:36 +00:00
|
|
|
|
2024-03-07 22:40:31 +00:00
|
|
|
crossterm = { workspace = true }
|
|
|
|
ctrlc = { workspace = true }
|
2024-07-16 12:16:26 +00:00
|
|
|
dirs = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
log = { workspace = true }
|
|
|
|
miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] }
|
2024-05-21 05:47:24 +00:00
|
|
|
mimalloc = { version = "0.1.42", default-features = false, optional = true }
|
2024-08-06 20:28:38 +00:00
|
|
|
multipart-rs = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
serde_json = { workspace = true }
|
2023-05-26 15:32:48 +00:00
|
|
|
simplelog = "0.12"
|
|
|
|
time = "0.3"
|
2022-02-22 15:55:28 +00:00
|
|
|
|
2022-05-26 18:28:59 +00:00
|
|
|
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
|
|
|
# Our dependencies don't use OpenSSL on Windows
|
2023-05-26 15:32:48 +00:00
|
|
|
openssl = { version = "0.10", features = ["vendored"], optional = true }
|
2022-05-26 18:28:59 +00:00
|
|
|
|
2022-10-16 21:51:15 +00:00
|
|
|
[target.'cfg(windows)'.build-dependencies]
|
2023-04-26 12:14:55 +00:00
|
|
|
winresource = "0.1"
|
2022-10-16 21:51:15 +00:00
|
|
|
|
|
|
|
[target.'cfg(target_family = "unix")'.dependencies]
|
2024-03-07 22:40:31 +00:00
|
|
|
nix = { workspace = true, default-features = false, features = [
|
|
|
|
"signal",
|
|
|
|
"process",
|
|
|
|
"fs",
|
|
|
|
"term",
|
`string | fill` counts clusters, not graphemes; and doesn't count ANSI escape codes (#8134)
Enhancement of new `fill` command (#7846) to handle content including
ANSI escape codes for formatting or multi-code-point Unicode grapheme
clusters.
In both of these cases, the content is (many) bytes longer than its
visible length, and `fill` was counting the extra bytes so not adding
enough fill characters.
# Description
This script:
```rust
# the teacher emoji `\u{1F9D1}\u{200D}\u{1F3EB}` is 3 code points, but only 1 print position wide.
echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"\u{1F9D1}\u{200D}\u{1F3EB}" | fill -c "+" -w 3 -a "c"
echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"(ansi green)a(ansi reset)" | fill -c "+" -w 3 -a c
echo ""
```
Was producing this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
🧑🏫
This output should be 3 print positions wide, with leading and trailing `+`
a
```
After this PR, it produces this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
+🧑🏫+
This output should be 3 print positions wide, with leading and trailing `+`
+a+
```
# User-Facing Changes
Users may have to undo fixes they may have introduced to work around the
former behavior. I have one such in my prompt string that I can now
revert.
# Tests + Formatting
Don't forget to add tests that cover your changes.
-- Done
Make sure you've run and fixed any issues with these commands:
- [x] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass
# After Submitting
`fill` command not documented in the book, and it still talks about `str
lpad/rpad`. I'll fix.
Note added dependency on a new library `print-positions`, which is an
iterator that yields a complete print position (cluster + Ansi sequence)
per call. Should this be vendored?
2023-02-20 12:32:20 +00:00
|
|
|
] }
|
2022-10-16 21:51:15 +00:00
|
|
|
|
2021-07-30 20:02:16 +00:00
|
|
|
[dev-dependencies]
|
2024-08-22 09:36:32 +00:00
|
|
|
nu-test-support = { path = "./crates/nu-test-support", version = "0.97.2" }
|
|
|
|
nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.97.2" }
|
|
|
|
nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.97.2" }
|
2023-05-26 15:32:48 +00:00
|
|
|
assert_cmd = "2.0"
|
2024-07-16 12:16:26 +00:00
|
|
|
dirs = { workspace = true }
|
Tango migration (#12469)
# Description
This PR migrates the benchmark suit to Tango. Its different compared to
other framework because it require 2 binaries, to run to do A/B
benchmarking, this is currently limited to Linux, Max, (Windows require
rustc nightly flag), by switching between two suits it can reduce noise
and run the code "almost" concurrently. I have have been in contact with
the maintainer, and bases this on the dev branch, as it had a newer API
simular to criterion. This framework compared to Divan also have a
simple file dump system if we want to generate graphs, do other analysis
on later. I think overall this crate is very nice, a lot faster to
compile and run then criterion, that's for sure.
2024-05-05 15:53:48 +00:00
|
|
|
tango-bench = "0.5"
|
2024-04-26 11:23:16 +00:00
|
|
|
pretty_assertions = { workspace = true }
|
Internal representation (IR) compiler and evaluator (#13330)
# Description
This PR adds an internal representation language to Nushell, offering an
alternative evaluator based on simple instructions, stream-containing
registers, and indexed control flow. The number of registers required is
determined statically at compile-time, and the fixed size required is
allocated upon entering the block.
Each instruction is associated with a span, which makes going backwards
from IR instructions to source code very easy.
Motivations for IR:
1. **Performance.** By simplifying the evaluation path and making it
more cache-friendly and branch predictor-friendly, code that does a lot
of computation in Nushell itself can be sped up a decent bit. Because
the IR is fairly easy to reason about, we can also implement
optimization passes in the future to eliminate and simplify code.
2. **Correctness.** The instructions mostly have very simple and
easily-specified behavior, so hopefully engine changes are a little bit
easier to reason about, and they can be specified in a more formal way
at some point. I have made an effort to document each of the
instructions in the docs for the enum itself in a reasonably specific
way. Some of the errors that would have happened during evaluation
before are now moved to the compilation step instead, because they don't
make sense to check during evaluation.
3. **As an intermediate target.** This is a good step for us to bring
the [`new-nu-parser`](https://github.com/nushell/new-nu-parser) in at
some point, as code generated from new AST can be directly compared to
code generated from old AST. If the IR code is functionally equivalent,
it will behave the exact same way.
4. **Debugging.** With a little bit more work, we can probably give
control over advancing the virtual machine that `IrBlock`s run on to
some sort of external driver, making things like breakpoints and single
stepping possible. Tools like `view ir` and [`explore
ir`](https://github.com/devyn/nu_plugin_explore_ir) make it easier than
before to see what exactly is going on with your Nushell code.
The goal is to eventually replace the AST evaluator entirely, once we're
sure it's working just as well. You can help dogfood this by running
Nushell with `$env.NU_USE_IR` set to some value. The environment
variable is checked when Nushell starts, so config runs with IR, or it
can also be set on a line at the REPL to change it dynamically. It is
also checked when running `do` in case within a script you want to just
run a specific piece of code with or without IR.
# Example
```nushell
view ir { |data|
mut sum = 0
for n in $data {
$sum += $n
}
$sum
}
```
```gas
# 3 registers, 19 instructions, 0 bytes of data
0: load-literal %0, int(0)
1: store-variable var 904, %0 # let
2: drain %0
3: drop %0
4: load-variable %1, var 903
5: iterate %0, %1, end 15 # for, label(1), from(14:)
6: store-variable var 905, %0
7: load-variable %0, var 904
8: load-variable %2, var 905
9: binary-op %0, Math(Plus), %2
10: span %0
11: store-variable var 904, %0
12: load-literal %0, nothing
13: drain %0
14: jump 5
15: drop %0 # label(0), from(5:)
16: drain %0
17: load-variable %0, var 904
18: return %0
```
# Benchmarks
All benchmarks run on a base model Mac Mini M1.
## Iterative Fibonacci sequence
This is about as best case as possible, making use of the much faster
control flow. Most code will not experience a speed improvement nearly
this large.
```nushell
def fib [n: int] {
mut a = 0
mut b = 1
for _ in 2..=$n {
let c = $a + $b
$a = $b
$b = $c
}
$b
}
use std bench
bench { 0..50 | each { |n| fib $n } }
```
IR disabled:
```
╭───────┬─────────────────╮
│ mean │ 1ms 924µs 665ns │
│ min │ 1ms 700µs 83ns │
│ max │ 3ms 450µs 125ns │
│ std │ 395µs 759ns │
│ times │ [list 50 items] │
╰───────┴─────────────────╯
```
IR enabled:
```
╭───────┬─────────────────╮
│ mean │ 452µs 820ns │
│ min │ 427µs 417ns │
│ max │ 540µs 167ns │
│ std │ 17µs 158ns │
│ times │ [list 50 items] │
╰───────┴─────────────────╯
```
![explore ir
view](https://github.com/nushell/nushell/assets/10729/d7bccc03-5222-461c-9200-0dce71b83b83)
##
[gradient_benchmark_no_check.nu](https://github.com/nushell/nu_scripts/blob/main/benchmarks/gradient_benchmark_no_check.nu)
IR disabled:
```
╭───┬──────────────────╮
│ 0 │ 27ms 929µs 958ns │
│ 1 │ 21ms 153µs 459ns │
│ 2 │ 18ms 639µs 666ns │
│ 3 │ 19ms 554µs 583ns │
│ 4 │ 13ms 383µs 375ns │
│ 5 │ 11ms 328µs 208ns │
│ 6 │ 5ms 659µs 542ns │
╰───┴──────────────────╯
```
IR enabled:
```
╭───┬──────────────────╮
│ 0 │ 22ms 662µs │
│ 1 │ 17ms 221µs 792ns │
│ 2 │ 14ms 786µs 708ns │
│ 3 │ 13ms 876µs 834ns │
│ 4 │ 13ms 52µs 875ns │
│ 5 │ 11ms 269µs 666ns │
│ 6 │ 6ms 942µs 500ns │
╰───┴──────────────────╯
```
##
[random-bytes.nu](https://github.com/nushell/nu_scripts/blob/main/benchmarks/random-bytes.nu)
I got pretty random results out of this benchmark so I decided not to
include it. Not clear why.
# User-Facing Changes
- IR compilation errors may appear even if the user isn't evaluating
with IR.
- IR evaluation can be enabled by setting the `NU_USE_IR` environment
variable to any value.
- New command `view ir` pretty-prints the IR for a block, and `view ir
--json` can be piped into an external tool like [`explore
ir`](https://github.com/devyn/nu_plugin_explore_ir).
# Tests + Formatting
All tests are passing with `NU_USE_IR=1`, and I've added some more eval
tests to compare the results for some very core operations. I will
probably want to add some more so we don't have to always check
`NU_USE_IR=1 toolkit test --workspace` on a regular basis.
# After Submitting
- [ ] release notes
- [ ] further documentation of instructions?
- [ ] post-release: publish `nu_plugin_explore_ir`
2024-07-11 00:33:59 +00:00
|
|
|
regex = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
rstest = { workspace = true, default-features = false }
|
2024-04-24 12:01:20 +00:00
|
|
|
serial_test = "3.1"
|
2024-03-07 22:40:31 +00:00
|
|
|
tempfile = { workspace = true }
|
2021-12-07 20:06:34 +00:00
|
|
|
|
|
|
|
[features]
|
2023-01-23 18:57:40 +00:00
|
|
|
plugin = [
|
2024-04-27 17:08:12 +00:00
|
|
|
"nu-plugin-engine",
|
2024-04-21 12:36:26 +00:00
|
|
|
"nu-cmd-plugin",
|
2024-03-07 22:40:31 +00:00
|
|
|
"nu-cli/plugin",
|
|
|
|
"nu-parser/plugin",
|
|
|
|
"nu-command/plugin",
|
|
|
|
"nu-protocol/plugin",
|
|
|
|
"nu-engine/plugin",
|
2023-01-23 18:57:40 +00:00
|
|
|
]
|
2024-08-28 20:19:13 +00:00
|
|
|
|
|
|
|
default = [
|
2024-03-07 22:40:31 +00:00
|
|
|
"plugin",
|
|
|
|
"trash-support",
|
|
|
|
"sqlite",
|
|
|
|
"mimalloc",
|
2024-01-20 14:04:06 +00:00
|
|
|
]
|
2021-12-07 20:06:34 +00:00
|
|
|
stable = ["default"]
|
2023-06-14 21:12:55 +00:00
|
|
|
# NOTE: individual features are also passed to `nu-cmd-lang` that uses them to generate the feature matrix in the `version` command
|
2022-11-21 17:24:25 +00:00
|
|
|
|
2023-10-10 23:13:28 +00:00
|
|
|
# Enable to statically link OpenSSL (perl is required, to build OpenSSL https://docs.rs/openssl/latest/openssl/);
|
2023-09-09 20:34:07 +00:00
|
|
|
# otherwise the system version will be used. Not enabled by default because it takes a while to build
|
2023-05-22 15:42:38 +00:00
|
|
|
static-link-openssl = ["dep:openssl", "nu-cmd-lang/static-link-openssl"]
|
2021-12-07 20:06:34 +00:00
|
|
|
|
2023-06-14 22:27:12 +00:00
|
|
|
mimalloc = ["nu-cmd-lang/mimalloc", "dep:mimalloc"]
|
2024-08-28 20:19:13 +00:00
|
|
|
# Optional system clipboard support in `reedline`, this behavior has problematic compatibility with some systems.
|
|
|
|
# Missing X server/ Wayland can cause issues
|
2024-04-18 14:33:41 +00:00
|
|
|
system-clipboard = [
|
|
|
|
"reedline/system_clipboard",
|
|
|
|
"nu-cli/system-clipboard",
|
|
|
|
"nu-cmd-lang/system-clipboard",
|
|
|
|
]
|
2023-06-14 22:27:12 +00:00
|
|
|
|
2021-12-07 20:06:34 +00:00
|
|
|
# Stable (Default)
|
2023-05-22 15:42:38 +00:00
|
|
|
trash-support = ["nu-command/trash-support", "nu-cmd-lang/trash-support"]
|
2022-01-20 18:02:53 +00:00
|
|
|
|
2022-11-23 00:58:11 +00:00
|
|
|
# SQLite commands for nushell
|
2023-05-22 15:42:38 +00:00
|
|
|
sqlite = ["nu-command/sqlite", "nu-cmd-lang/sqlite"]
|
2022-04-24 09:29:21 +00:00
|
|
|
|
2021-12-07 20:06:34 +00:00
|
|
|
[profile.release]
|
2023-01-23 18:57:40 +00:00
|
|
|
opt-level = "s" # Optimize for size
|
2022-02-28 12:13:24 +00:00
|
|
|
strip = "debuginfo"
|
2022-03-10 13:37:24 +00:00
|
|
|
lto = "thin"
|
2022-02-28 12:13:24 +00:00
|
|
|
|
2022-03-16 22:21:06 +00:00
|
|
|
# build with `cargo build --profile profiling`
|
2022-02-28 12:13:24 +00:00
|
|
|
# to analyze performance with tooling like linux perf
|
|
|
|
[profile.profiling]
|
|
|
|
inherits = "release"
|
|
|
|
strip = false
|
|
|
|
debug = true
|
2021-12-07 20:06:34 +00:00
|
|
|
|
2022-05-16 04:02:11 +00:00
|
|
|
# build with `cargo build --profile ci`
|
|
|
|
# to analyze performance with tooling like linux perf
|
|
|
|
[profile.ci]
|
|
|
|
inherits = "dev"
|
|
|
|
strip = false
|
|
|
|
debug = false
|
|
|
|
|
2019-12-10 00:05:40 +00:00
|
|
|
# Main nu binary
|
2019-06-27 04:56:48 +00:00
|
|
|
[[bin]]
|
|
|
|
name = "nu"
|
|
|
|
path = "src/main.rs"
|
2023-02-12 22:22:00 +00:00
|
|
|
bench = false
|
2022-09-29 18:37:48 +00:00
|
|
|
|
2022-10-17 21:45:28 +00:00
|
|
|
# To use a development version of a dependency please use a global override here
|
|
|
|
# changing versions in each sub-crate of the workspace is tedious
|
2024-08-05 12:59:34 +00:00
|
|
|
[patch.crates-io]
|
2024-09-06 14:57:45 +00:00
|
|
|
reedline = { git = "https://github.com/nushell/reedline", branch = "main" }
|
2023-03-13 22:38:18 +00:00
|
|
|
# nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"}
|
2023-01-05 19:39:54 +00:00
|
|
|
|
|
|
|
# Run all benchmarks with `cargo bench`
|
|
|
|
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`
|
|
|
|
[[bench]]
|
2023-01-11 01:51:25 +00:00
|
|
|
name = "benchmarks"
|
2024-07-31 16:14:50 +00:00
|
|
|
harness = false
|