From 81e496673e7a96075c65013027b11e09946ae177 Mon Sep 17 00:00:00 2001 From: zc he Date: Tue, 11 Mar 2025 19:13:58 +0800 Subject: [PATCH 01/59] refactor(lsp): span fix made easy by bumping lsp-textdocument to 0.4.2 (#15287) # Description The upstream crate fixed a bug of position calc, which made some extra checking in lsp unnecessary. Also moved some follow-up fixing of #15238 from #15270 here, as it has something to do with previous position calc bug. # User-Facing Changes # Tests + Formatting Adjusted # After Submitting --- Cargo.lock | 6 +-- Cargo.toml | 2 +- crates/nu-cli/src/completions/completer.rs | 3 +- crates/nu-lsp/src/completion.rs | 54 +++++++++++----------- crates/nu-lsp/src/semantic_tokens.rs | 12 ++--- 5 files changed, 34 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a536440a9..8358295a59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3105,9 +3105,9 @@ dependencies = [ [[package]] name = "lsp-textdocument" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a17dcde15cae78fb2e54166da22cd6c53f48033a0391cc392b22f2437805792" +checksum = "2d564d595f4e3dcd3c071bf472dbd2cac53bc3665ae7222d2abfecd18feaed2c" dependencies = [ "lsp-types", "serde_json", @@ -8078,7 +8078,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a1d5aeb0c5..bb6b35246c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,7 +104,7 @@ lru = "0.12" lscolors = { version = "0.17", default-features = false } lsp-server = "0.7.8" lsp-types = { version = "0.97.0", features = ["proposed"] } -lsp-textdocument = "0.4.1" +lsp-textdocument = "0.4.2" mach2 = "0.4" md5 = { version = "0.10", package = "md-5" } miette = "7.5" diff --git a/crates/nu-cli/src/completions/completer.rs b/crates/nu-cli/src/completions/completer.rs index d0e045e3c8..ec0c10effe 100644 --- a/crates/nu-cli/src/completions/completer.rs +++ b/crates/nu-cli/src/completions/completer.rs @@ -307,9 +307,8 @@ impl NuCompleter { let need_externals = !prefix_str.contains(' '); let need_internals = !prefix_str.starts_with('^'); let mut span = element_expression.span; - span.end = std::cmp::min(span.end, pos + 1); if !need_internals { - span = Span::new(span.start + 1, span.end) + span.start += 1; }; suggestions.extend(self.command_completion_helper( working_set, diff --git a/crates/nu-lsp/src/completion.rs b/crates/nu-lsp/src/completion.rs index e9bbd98c8a..16ae33567f 100644 --- a/crates/nu-lsp/src/completion.rs +++ b/crates/nu-lsp/src/completion.rs @@ -1,13 +1,15 @@ use std::sync::Arc; -use crate::{uri_to_path, LanguageServer}; +use crate::{span_to_range, uri_to_path, LanguageServer}; use lsp_types::{ CompletionItem, CompletionItemKind, CompletionItemLabelDetails, CompletionParams, - CompletionResponse, CompletionTextEdit, Documentation, MarkupContent, MarkupKind, Range, - TextEdit, + CompletionResponse, CompletionTextEdit, Documentation, MarkupContent, MarkupKind, TextEdit, }; use nu_cli::{NuCompleter, SuggestionKind}; -use nu_protocol::engine::{CommandType, Stack}; +use nu_protocol::{ + engine::{CommandType, Stack}, + Span, +}; impl LanguageServer { pub(crate) fn complete(&mut self, params: &CompletionParams) -> Option { @@ -44,17 +46,12 @@ impl LanguageServer { ) }; + let docs = self.docs.lock().ok()?; + let file = docs.get_document(&path_uri)?; (!results.is_empty()).then_some(CompletionResponse::Array( results .into_iter() .map(|r| { - let mut start = params.text_document_position.position; - start.character = start.character.saturating_sub( - r.suggestion - .span - .end - .saturating_sub(r.suggestion.span.start) as u32, - ); let decl_id = r.kind.clone().and_then(|kind| { matches!(kind, SuggestionKind::Command(_)) .then_some(engine_state.find_decl(r.suggestion.value.as_bytes(), &[])?) @@ -64,8 +61,17 @@ impl LanguageServer { if r.suggestion.append_whitespace { label_value.push(' '); } + + let span = r.suggestion.span; + let range = span_to_range(&Span::new(span.start, span.end), file, 0); + + let text_edit = Some(CompletionTextEdit::Edit(TextEdit { + range, + new_text: label_value.clone(), + })); + CompletionItem { - label: label_value.clone(), + label: label_value, label_details: r .kind .clone() @@ -97,13 +103,7 @@ impl LanguageServer { }) }), kind: Self::lsp_completion_item_kind(r.kind), - text_edit: Some(CompletionTextEdit::Edit(TextEdit { - range: Range { - start, - end: params.text_document_position.position, - }, - new_text: label_value, - })), + text_edit, ..Default::default() } }) @@ -230,16 +230,14 @@ mod tests { actual: result_from_message(resp), expected: serde_json::json!([ // defined after the cursor - { - "label": "config ", - "detail": "Edit nushell configuration files.", - "textEdit": { "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 6 }, }, - "newText": "config " - }, - }, - { "label": "config env ", "kind": 3 }, - { "label": "config flatten ", "kind": 3 }, { "label": "config n foo bar ", "detail": detail_str, "kind": 2 }, + { + "label": "config nu ", + "detail": "Edit nu configurations.", + "textEdit": { "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 8 }, }, + "newText": "config nu " + } + }, ]) ); diff --git a/crates/nu-lsp/src/semantic_tokens.rs b/crates/nu-lsp/src/semantic_tokens.rs index 6a963f40b4..cd5a65f7e0 100644 --- a/crates/nu-lsp/src/semantic_tokens.rs +++ b/crates/nu-lsp/src/semantic_tokens.rs @@ -80,27 +80,21 @@ impl LanguageServer { if sp < last_span { continue; } - // in case the start position is at the end of lastline - let real_start_char = if range.end.line != range.start.line { - 0 - } else { - range.start.character - }; - let mut delta_start = real_start_char; + let mut delta_start = range.start.character; if range.end.line == last_token_line { delta_start -= last_token_char; } tokens.push(SemanticToken { delta_start, delta_line: range.end.line.saturating_sub(last_token_line), - length: range.end.character.saturating_sub(real_start_char), + length: range.end.character.saturating_sub(range.start.character), // 0 means function in semantic_token_legend token_type: 0, token_modifiers_bitset: 0, }); last_span = sp; last_token_line = range.end.line; - last_token_char = real_start_char; + last_token_char = range.start.character; } tokens } From b432866dc96a6b26c3a5c824eae4aac62e66d445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= <96702577+LoicRiegel@users.noreply.github.com> Date: Tue, 11 Mar 2025 14:40:26 +0100 Subject: [PATCH 02/59] bugfix: math commands now return error with infinite range [#15135] (#15236) ### Description Fixes issue #15135 Result ![image](https://github.com/user-attachments/assets/9ff4397f-db79-46df-b1da-2d09f50dd63f) Also this works with other commands: min, max, sum, product, avg... ### User-Facing Changes Error is returned, instead of console completely blocked and having to be killed I chose "Incorrect value", because commands accept inputs of range type, just cannot work with unbounded ranges. ### Tests + Formatting - ran cargo fmt, clippy - added tests --- crates/nu-command/src/math/utils.rs | 25 +++++++++++++++++-- crates/nu-command/tests/commands/math/abs.rs | 7 ++++++ crates/nu-command/tests/commands/math/avg.rs | 14 +++++++++++ crates/nu-command/tests/commands/math/ceil.rs | 7 ++++++ .../nu-command/tests/commands/math/floor.rs | 7 ++++++ crates/nu-command/tests/commands/math/log.rs | 7 ++++++ crates/nu-command/tests/commands/math/max.rs | 7 ++++++ .../nu-command/tests/commands/math/median.rs | 7 ++++++ crates/nu-command/tests/commands/math/min.rs | 7 ++++++ crates/nu-command/tests/commands/math/mode.rs | 7 ++++++ .../nu-command/tests/commands/math/product.rs | 7 ++++++ .../nu-command/tests/commands/math/round.rs | 7 ++++++ crates/nu-command/tests/commands/math/sqrt.rs | 7 ++++++ .../nu-command/tests/commands/math/stddev.rs | 7 ++++++ crates/nu-command/tests/commands/math/sum.rs | 7 ++++++ .../tests/commands/math/variance.rs | 7 ++++++ crates/nu-pretty-hex/README.md | 2 +- 17 files changed, 136 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/math/utils.rs b/crates/nu-command/src/math/utils.rs index 62f96ea073..e9b87b2df1 100644 --- a/crates/nu-command/src/math/utils.rs +++ b/crates/nu-command/src/math/utils.rs @@ -1,6 +1,8 @@ -use core::slice; +use core::{ops::Bound, slice}; use indexmap::IndexMap; -use nu_protocol::{engine::Call, IntoPipelineData, PipelineData, ShellError, Signals, Span, Value}; +use nu_protocol::{ + engine::Call, IntoPipelineData, PipelineData, Range, ShellError, Signals, Span, Value, +}; pub fn run_with_function( call: &Call, @@ -91,6 +93,10 @@ pub fn calculate( Ok(Value::record(record, span)) } PipelineData::Value(Value::Range { val, .. }, ..) => { + match *val { + Range::IntRange(range) => ensure_bounded(range.end(), span, name)?, + Range::FloatRange(range) => ensure_bounded(range.end(), span, name)?, + } let new_vals: Result, ShellError> = val .into_range_iter(span, Signals::empty()) .map(|val| mf(&[val], span, name)) @@ -110,3 +116,18 @@ pub fn calculate( }), } } + +pub fn ensure_bounded( + bound: Bound, + val_span: Span, + call_span: Span, +) -> Result<(), ShellError> { + match bound { + Bound::::Unbounded => Err(ShellError::IncorrectValue { + msg: "Range must be bounded".to_string(), + val_span, + call_span, + }), + _ => Ok(()), + } +} diff --git a/crates/nu-command/tests/commands/math/abs.rs b/crates/nu-command/tests/commands/math/abs.rs index 4d61c8ed11..de5c7551aa 100644 --- a/crates/nu-command/tests/commands/math/abs.rs +++ b/crates/nu-command/tests/commands/math/abs.rs @@ -5,3 +5,10 @@ fn const_abs() { let actual = nu!("const ABS = -5.5 | math abs; $ABS"); assert_eq!(actual.out, "5.5"); } + +#[test] +fn cannot_abs_range() { + let actual = nu!("0..5 | math abs"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/avg.rs b/crates/nu-command/tests/commands/math/avg.rs index 744b2f6067..ec9a124b7b 100644 --- a/crates/nu-command/tests/commands/math/avg.rs +++ b/crates/nu-command/tests/commands/math/avg.rs @@ -21,6 +21,20 @@ fn can_average_bytes() { assert_eq!(actual.out, "34985870"); } +#[test] +fn can_average_range() { + let actual = nu!("0..5 | math avg"); + + assert_eq!(actual.out, "2.5"); +} + +#[test] +fn cannot_average_infinite_range() { + let actual = nu!("0.. | math avg"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} + #[test] fn const_avg() { let actual = nu!("const AVG = [1 3 5] | math avg; $AVG"); diff --git a/crates/nu-command/tests/commands/math/ceil.rs b/crates/nu-command/tests/commands/math/ceil.rs index 760fb0a503..f9c753d1dd 100644 --- a/crates/nu-command/tests/commands/math/ceil.rs +++ b/crates/nu-command/tests/commands/math/ceil.rs @@ -5,3 +5,10 @@ fn const_ceil() { let actual = nu!("const CEIL = 1.5 | math ceil; $CEIL"); assert_eq!(actual.out, "2"); } + +#[test] +fn cannot_ceil_range() { + let actual = nu!("0..5 | math ceil"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/floor.rs b/crates/nu-command/tests/commands/math/floor.rs index 91184c8f58..5517233caa 100644 --- a/crates/nu-command/tests/commands/math/floor.rs +++ b/crates/nu-command/tests/commands/math/floor.rs @@ -5,3 +5,10 @@ fn const_floor() { let actual = nu!("const FLOOR = 15.5 | math floor; $FLOOR"); assert_eq!(actual.out, "15"); } + +#[test] +fn cannot_floor_range() { + let actual = nu!("0.. | math floor"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/log.rs b/crates/nu-command/tests/commands/math/log.rs index a8e54689b5..db69378e41 100644 --- a/crates/nu-command/tests/commands/math/log.rs +++ b/crates/nu-command/tests/commands/math/log.rs @@ -5,3 +5,10 @@ fn const_log() { let actual = nu!("const LOG = 16 | math log 2; $LOG"); assert_eq!(actual.out, "4"); } + +#[test] +fn cannot_log_range() { + let actual = nu!("0.. | math log 2"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/max.rs b/crates/nu-command/tests/commands/math/max.rs index cd940d3811..1ad715b68f 100644 --- a/crates/nu-command/tests/commands/math/max.rs +++ b/crates/nu-command/tests/commands/math/max.rs @@ -5,3 +5,10 @@ fn const_max() { let actual = nu!("const MAX = [1 3 5] | math max; $MAX"); assert_eq!(actual.out, "5"); } + +#[test] +fn cannot_max_infinite_range() { + let actual = nu!("0.. | math max"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} diff --git a/crates/nu-command/tests/commands/math/median.rs b/crates/nu-command/tests/commands/math/median.rs index 5e118e3b06..ba98305326 100644 --- a/crates/nu-command/tests/commands/math/median.rs +++ b/crates/nu-command/tests/commands/math/median.rs @@ -41,3 +41,10 @@ fn const_median() { let actual = nu!("const MEDIAN = [1 3 5] | math median; $MEDIAN"); assert_eq!(actual.out, "3"); } + +#[test] +fn cannot_median_infinite_range() { + let actual = nu!("0.. | math median"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} diff --git a/crates/nu-command/tests/commands/math/min.rs b/crates/nu-command/tests/commands/math/min.rs index 1384562c08..f7d4ab7317 100644 --- a/crates/nu-command/tests/commands/math/min.rs +++ b/crates/nu-command/tests/commands/math/min.rs @@ -5,3 +5,10 @@ fn const_min() { let actual = nu!("const MIN = [1 3 5] | math min; $MIN"); assert_eq!(actual.out, "1"); } + +#[test] +fn cannot_min_infinite_range() { + let actual = nu!("0.. | math min"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} diff --git a/crates/nu-command/tests/commands/math/mode.rs b/crates/nu-command/tests/commands/math/mode.rs index 160d2b6897..8a8f235257 100644 --- a/crates/nu-command/tests/commands/math/mode.rs +++ b/crates/nu-command/tests/commands/math/mode.rs @@ -5,3 +5,10 @@ fn const_avg() { let actual = nu!("const MODE = [1 3 3 5] | math mode; $MODE"); assert_eq!(actual.out, "╭───┬───╮│ 0 │ 3 │╰───┴───╯"); } + +#[test] +fn cannot_mode_range() { + let actual = nu!("0..5 | math mode"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/product.rs b/crates/nu-command/tests/commands/math/product.rs index f31ba9c6bc..c51db825a8 100644 --- a/crates/nu-command/tests/commands/math/product.rs +++ b/crates/nu-command/tests/commands/math/product.rs @@ -5,3 +5,10 @@ fn const_product() { let actual = nu!("const PROD = [1 3 5] | math product; $PROD"); assert_eq!(actual.out, "15"); } + +#[test] +fn cannot_product_infinite_range() { + let actual = nu!("0.. | math product"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} diff --git a/crates/nu-command/tests/commands/math/round.rs b/crates/nu-command/tests/commands/math/round.rs index 61a3199701..2c3badad5e 100644 --- a/crates/nu-command/tests/commands/math/round.rs +++ b/crates/nu-command/tests/commands/math/round.rs @@ -40,3 +40,10 @@ fn const_round() { let actual = nu!("const ROUND = 18.345 | math round; $ROUND"); assert_eq!(actual.out, "18"); } + +#[test] +fn cannot_round_infinite_range() { + let actual = nu!("0..5 | math round"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/sqrt.rs b/crates/nu-command/tests/commands/math/sqrt.rs index a0ba35b233..9f5cc55f88 100644 --- a/crates/nu-command/tests/commands/math/sqrt.rs +++ b/crates/nu-command/tests/commands/math/sqrt.rs @@ -26,3 +26,10 @@ fn const_sqrt() { let actual = nu!("const SQRT = 4 | math sqrt; $SQRT"); assert_eq!(actual.out, "2"); } + +#[test] +fn cannot_sqrt_range() { + let actual = nu!("0..5 | math sqrt"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/stddev.rs b/crates/nu-command/tests/commands/math/stddev.rs index 83fc472396..f1688c2d7a 100644 --- a/crates/nu-command/tests/commands/math/stddev.rs +++ b/crates/nu-command/tests/commands/math/stddev.rs @@ -5,3 +5,10 @@ fn const_avg() { let actual = nu!("const SDEV = [1 2] | math stddev; $SDEV"); assert_eq!(actual.out, "0.5"); } + +#[test] +fn cannot_stddev_range() { + let actual = nu!("0..5 | math stddev"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-command/tests/commands/math/sum.rs b/crates/nu-command/tests/commands/math/sum.rs index 020ce552c9..0a367f839b 100644 --- a/crates/nu-command/tests/commands/math/sum.rs +++ b/crates/nu-command/tests/commands/math/sum.rs @@ -81,3 +81,10 @@ fn const_sum() { let actual = nu!("const SUM = [1 3] | math sum; $SUM"); assert_eq!(actual.out, "4"); } + +#[test] +fn cannot_sum_infinite_range() { + let actual = nu!("0.. | math sum"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); +} diff --git a/crates/nu-command/tests/commands/math/variance.rs b/crates/nu-command/tests/commands/math/variance.rs index 1e27484bf0..1573a131bb 100644 --- a/crates/nu-command/tests/commands/math/variance.rs +++ b/crates/nu-command/tests/commands/math/variance.rs @@ -5,3 +5,10 @@ fn const_variance() { let actual = nu!("const VAR = [1 2 3 4 5] | math variance; $VAR"); assert_eq!(actual.out, "2"); } + +#[test] +fn cannot_variance_range() { + let actual = nu!("0..5 | math variance"); + + assert!(actual.err.contains("nu::parser::input_type_mismatch")); +} diff --git a/crates/nu-pretty-hex/README.md b/crates/nu-pretty-hex/README.md index 7c640cc28f..3a485a2701 100644 --- a/crates/nu-pretty-hex/README.md +++ b/crates/nu-pretty-hex/README.md @@ -1,6 +1,6 @@ # nu-pretty-hex -An update of prett-hex to make it prettier +An update of pretty-hex to make it prettier [![crates.io](https://img.shields.io/crates/v/pretty-hex.svg)](https://crates.io/crates/pretty-hex) [![docs.rs](https://docs.rs/pretty-hex/badge.svg)](https://docs.rs/pretty-hex) From 58f7cfd0993bfe328128879f00406e40e497f34a Mon Sep 17 00:00:00 2001 From: Piepmatz Date: Tue, 11 Mar 2025 14:55:35 +0100 Subject: [PATCH 03/59] Test on Beta Toolchain (#15280) # Description In the [Nushell core team meeting 2025-02-19](https://hackmd.io/r3V83bMdQqKMwFxz90nBDg?view) we decided to run tests on the beta toolchain to contribute to the Rust project as a whole. These tests do not need to succeed for us to go further but allow us to investigate if the beta toolchain broke something. # User-Facing Changes None. # Tests + Formatting Just a new workflow. # After Submitting Watch out for modification of this file changing the notified person --- .github/workflows/beta-test.yml | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/beta-test.yml diff --git a/.github/workflows/beta-test.yml b/.github/workflows/beta-test.yml new file mode 100644 index 0000000000..7770c6a83c --- /dev/null +++ b/.github/workflows/beta-test.yml @@ -0,0 +1,52 @@ +name: Test on Beta Toolchain +# This workflow is made to run our tests on the beta toolchain to validate that +# the beta toolchain works. +# We do not intend to test here that we are working correctly but rather that +# the beta toolchain works correctly. +# The ci.yml handles our actual testing with our guarantees. + +on: + schedule: + # If this workflow fails, GitHub notifications will go to the last person + # who edited this line. + # See: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/notifications-for-workflow-runs + - cron: '0 0 * * *' # Runs daily at midnight UTC + +env: + NUSHELL_CARGO_PROFILE: ci + NU_LOG_LEVEL: DEBUG + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + build-and-test: + # this job is more for testing the beta toolchain and not our tests, so if + # this fails but the tests of the regular ci pass, then this is fine + continue-on-error: true + + strategy: + fail-fast: true + matrix: + platform: [windows-latest, macos-latest, ubuntu-22.04] + + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + + - run: rustup update beta + + - name: Tests + run: cargo +beta test --workspace --profile ci --exclude nu_plugin_* + - name: Check for clean repo + shell: bash + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "there are changes"; + git status --porcelain + exit 1 + else + echo "no changes in working directory"; + fi From 8d5d01bbc950f0bd3bad46f318438d2300664cca Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Tue, 11 Mar 2025 11:57:37 -0400 Subject: [PATCH 04/59] Fix improper application of local timezone offset to Unix epochs (#15283) Fix failing test by ignoring the local offset when converting times, but still displaying the resulting date in the local timezone (including applicable DST offset). # User-Facing Changes Fix: Unix Epochs now convert consistently regardless of whether DST is in effect in the local timezone or not. --- crates/nu-command/src/conversions/into/datetime.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 0fc9725bcf..54930bbc45 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -408,13 +408,10 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value { Err(reason) => { match NaiveDateTime::parse_from_str(val, &dt.0) { Ok(d) => { - let local_offset = *Local::now().offset(); let dt_fixed = - TimeZone::from_local_datetime(&local_offset, &d) - .single() - .unwrap_or_default(); + Local.from_local_datetime(&d).single().unwrap_or_default(); - Value::date (dt_fixed,head) + Value::date(dt_fixed.into(),head) } Err(_) => { Value::error ( From e926919582138fe6025080469d5b66d817aa8570 Mon Sep 17 00:00:00 2001 From: Jack Wright <56345+ayax79@users.noreply.github.com> Date: Tue, 11 Mar 2025 14:18:36 -0700 Subject: [PATCH 05/59] `polars open`: exposing the ability to configure hive settings. (#15255) # Description Exposes parameters for working with [hive](https://docs.pola.rs/user-guide/io/hive/#scanning-hive-partitioned-data) partitioning. # User-Facing Changes - Added flags `--hive-enabled`, `--hive-start-idx`, `--hive-schema`, `--hive-try-parse-dates` to `polars open` --- .../src/dataframe/command/core/open.rs | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/crates/nu_plugin_polars/src/dataframe/command/core/open.rs b/crates/nu_plugin_polars/src/dataframe/command/core/open.rs index f9620290db..0cbad49dd0 100644 --- a/crates/nu_plugin_polars/src/dataframe/command/core/open.rs +++ b/crates/nu_plugin_polars/src/dataframe/command/core/open.rs @@ -7,7 +7,7 @@ use crate::{ use log::debug; use nu_utils::perf; -use nu_plugin::PluginCommand; +use nu_plugin::{EvaluatedCall, PluginCommand}; use nu_protocol::{ shell_error::io::IoError, Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, @@ -90,6 +90,28 @@ impl PluginCommand for OpenDataFrame { r#"Polars Schema in format [{name: str}]. CSV, JSON, and JSONL files"#, Some('s') ) + .switch( + "hive-enabled", + "Enable hive support. Parquet and Arrow files", + None, + ) + .named( + "hive-start-idx", + SyntaxShape::Number, + "Start index of hive partitioning. Parquet and Arrow files", + None, + ) + .named( + "hive-schema", + SyntaxShape::Record(vec![]), + r#"Hive schema in format [{name: str}]. Parquet and Arrow files"#, + None, + ) + .switch( + "hive-try-parse-dates", + "Try to parse dates in hive partitioning. Parquet and Arrow files", + None, + ) .switch("truncate-ragged-lines", "Truncate lines that are longer than the schema. CSV file", None) .input_output_type(Type::Any, Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) @@ -141,13 +163,19 @@ fn command( }); } + let hive_options = build_hive_options(call)?; + match type_option { Some((ext, blamed)) => match PolarsFileType::from(ext.as_str()) { PolarsFileType::Csv | PolarsFileType::Tsv => { from_csv(plugin, engine, call, resource, is_eager) } - PolarsFileType::Parquet => from_parquet(plugin, engine, call, resource, is_eager), - PolarsFileType::Arrow => from_arrow(plugin, engine, call, resource, is_eager), + PolarsFileType::Parquet => { + from_parquet(plugin, engine, call, resource, is_eager, hive_options) + } + PolarsFileType::Arrow => { + from_arrow(plugin, engine, call, resource, is_eager, hive_options) + } PolarsFileType::Json => from_json(plugin, engine, call, resource, is_eager), PolarsFileType::NdJson => from_ndjson(plugin, engine, call, resource, is_eager), PolarsFileType::Avro => from_avro(plugin, engine, call, resource, is_eager), @@ -180,12 +208,14 @@ fn from_parquet( call: &nu_plugin::EvaluatedCall, resource: Resource, is_eager: bool, + hive_options: HiveOptions, ) -> Result { let file_path = resource.path; let file_span = resource.span; if !is_eager { let args = ScanArgsParquet { cloud_options: resource.cloud_options, + hive_options, ..Default::default() }; let df: NuLazyFrame = LazyFrame::scan_parquet(file_path, args) @@ -279,6 +309,7 @@ fn from_arrow( call: &nu_plugin::EvaluatedCall, resource: Resource, is_eager: bool, + hive_options: HiveOptions, ) -> Result { let file_path = resource.path; let file_span = resource.span; @@ -290,7 +321,7 @@ fn from_arrow( row_index: None, cloud_options: resource.cloud_options, include_file_paths: None, - hive_options: HiveOptions::default(), + hive_options, }; let df: NuLazyFrame = LazyFrame::scan_ipc(file_path, args) @@ -595,3 +626,20 @@ fn cloud_not_supported(file_type: PolarsFileType, span: Span) -> ShellError { inner: vec![], } } + +fn build_hive_options(call: &EvaluatedCall) -> Result { + let enabled: Option = call.get_flag("hive-enabled")?; + let hive_start_idx: Option = call.get_flag("hive-start-idx")?; + let schema: Option = call + .get_flag::("hive-schema")? + .map(|schema| NuSchema::try_from(&schema)) + .transpose()?; + let try_parse_dates: bool = call.has_flag("hive-try-parse-dates")?; + + Ok(HiveOptions { + enabled, + hive_start_idx: hive_start_idx.unwrap_or(0), + schema: schema.map(|s| s.into()), + try_parse_dates, + }) +} From 789781665dfe136e16e886f698ab0bdcc706bb37 Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 12 Mar 2025 20:35:28 +0800 Subject: [PATCH 06/59] fix(lsp): find_id for custom def in custom def (#15289) # Description Enables hover/rename/references for: ```nushell def foo [] { def bar [] { } # |____________ this custom command } ``` # User-Facing Changes # Tests + Formatting +1 # After Submitting --- crates/nu-lsp/src/ast.rs | 12 +++++++++++- crates/nu-lsp/src/lib.rs | 24 ++++++++++++++++++++++++ tests/fixtures/lsp/hover/command.nu | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/crates/nu-lsp/src/ast.rs b/crates/nu-lsp/src/ast.rs index 5698d836d0..187d675c24 100644 --- a/crates/nu-lsp/src/ast.rs +++ b/crates/nu-lsp/src/ast.rs @@ -74,7 +74,17 @@ fn try_find_id_in_def( } let span = strip_quotes(span?, working_set); let name = working_set.get_span_contents(span); - let decl_id = Id::Declaration(working_set.find_decl(name)?); + let decl_id = Id::Declaration(working_set.find_decl(name).or_else(|| { + // for defs inside def + // TODO: get scope by position + // https://github.com/nushell/nushell/issues/15291 + (0..working_set.num_decls()).find_map(|id| { + let decl_id = nu_protocol::DeclId::new(id); + let decl = working_set.get_decl(decl_id); + let span = working_set.get_block(decl.block_id()?).span?; + call.span().contains_span(span).then_some(decl_id) + }) + })?); id_ref .is_none_or(|id_r| decl_id == *id_r) .then_some((decl_id, span)) diff --git a/crates/nu-lsp/src/lib.rs b/crates/nu-lsp/src/lib.rs index 9d05d44516..a61341c1e9 100644 --- a/crates/nu-lsp/src/lib.rs +++ b/crates/nu-lsp/src/lib.rs @@ -957,6 +957,30 @@ mod tests { ); } + #[test] + fn hover_on_custom_in_custom() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("command.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 9, 7); + + assert_json_eq!( + result_from_message(resp), + serde_json::json!({ + "contents": { + "kind": "markdown", + "value": "\n---\n### Usage \n```nu\n bar {flags}\n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n" + } + }) + ); + } + #[test] fn hover_on_external_command() { let (client_connection, _recv) = initialize_language_server(None, None); diff --git a/tests/fixtures/lsp/hover/command.nu b/tests/fixtures/lsp/hover/command.nu index d9df49ba4d..e83065fcf3 100644 --- a/tests/fixtures/lsp/hover/command.nu +++ b/tests/fixtures/lsp/hover/command.nu @@ -5,3 +5,7 @@ hello [""] | str join ^sleep + +def foo [] { + def bar [] { } +} From 1e566adcfc24364efeb3cafd23d494cc11ba685e Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 12 Mar 2025 21:04:20 +0800 Subject: [PATCH 07/59] fix(completion): full set of operators for type any (#15303) # Description As elaborated [here](https://github.com/nushell/nushell/issues/13676#issuecomment-2717096417), a full set probably is a more thoughtful approximation for unknown types. # User-Facing Changes # Tests + Formatting Adjusted # After Submitting --- .../src/completions/operator_completions.rs | 24 ++++++++++++++++--- crates/nu-cli/tests/completions/mod.rs | 7 ++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/nu-cli/src/completions/operator_completions.rs b/crates/nu-cli/src/completions/operator_completions.rs index b102b2c327..3d1db30673 100644 --- a/crates/nu-cli/src/completions/operator_completions.rs +++ b/crates/nu-cli/src/completions/operator_completions.rs @@ -37,6 +37,15 @@ fn common_comparison_ops() -> Vec { ] } +fn all_ops_for_immutable() -> Vec { + ast::Comparison::iter() + .map(operator_to_item) + .chain(ast::Math::iter().map(operator_to_item)) + .chain(ast::Boolean::iter().map(operator_to_item)) + .chain(ast::Bits::iter().map(operator_to_item)) + .collect() +} + fn collection_comparison_ops() -> Vec { let mut ops = common_comparison_ops(); ops.push(operator_to_item(Comparison::Has)); @@ -72,6 +81,10 @@ fn bit_ops() -> Vec { ast::Bits::iter().map(operator_to_item).collect() } +fn all_assignment_ops() -> Vec { + ast::Assignment::iter().map(operator_to_item).collect() +} + fn numeric_assignment_ops() -> Vec { ast::Assignment::iter() .filter(|op| !matches!(op, ast::Assignment::ConcatenateAssign)) @@ -154,7 +167,7 @@ fn ops_by_value(value: &Value, mutable: bool) -> Vec { Value::Filesize { .. } | Value::Duration { .. } => valid_value_with_unit_ops(), Value::Range { .. } | Value::Record { .. } => collection_comparison_ops(), Value::List { .. } => valid_list_ops(), - _ => common_comparison_ops(), + _ => all_ops_for_immutable(), }; if mutable { ops.extend(match value { @@ -165,7 +178,11 @@ fn ops_by_value(value: &Value, mutable: bool) -> Vec { Value::String { .. } | Value::Binary { .. } | Value::List { .. } => { concat_assignment_ops() } - _ => vec![operator_to_item(ast::Assignment::Assign)], + Value::Bool { .. } + | Value::Date { .. } + | Value::Range { .. } + | Value::Record { .. } => vec![operator_to_item(ast::Assignment::Assign)], + _ => all_assignment_ops(), }) } ops @@ -223,7 +240,7 @@ impl Completer for OperatorCompletion<'_> { needs_assignment_ops = false; ops_by_value(&value, mutable) } - _ => common_comparison_ops(), + _ => all_ops_for_immutable(), }, _ => common_comparison_ops(), }; @@ -233,6 +250,7 @@ impl Completer for OperatorCompletion<'_> { Type::Int | Type::Float | Type::Number => numeric_assignment_ops(), Type::Filesize | Type::Duration => numeric_assignment_ops(), Type::String | Type::Binary | Type::List(_) => concat_assignment_ops(), + Type::Any => all_assignment_ops(), _ => vec![operator_to_item(ast::Assignment::Assign)], }); } diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index f0c9fcaef0..8c29c83ebc 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -2345,6 +2345,13 @@ fn assignment_operator_completions(mut custom_completer: NuCompleter) { let expected: Vec<_> = vec!["++", "++="]; let suggestions = custom_completer.complete("$env.config.keybindings +", 25); match_suggestions(&expected, &suggestions); + + // all operators for type any + let suggestions = custom_completer.complete("ls | where name ", 16); + assert_eq!(30, suggestions.len()); + let expected: Vec<_> = vec!["starts-with"]; + let suggestions = custom_completer.complete("ls | where name starts", 22); + match_suggestions(&expected, &suggestions); } #[test] From 430b2746b805b06a9c7d3c392ac90761e6de4ab8 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Wed, 12 Mar 2025 09:09:55 -0400 Subject: [PATCH 08/59] Parse XML documents with DTDs by default, and add `--disallow-dtd` flag (#15272) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR allows `from xml` to parse XML documents with [document type declarations](https://en.wikipedia.org/wiki/Document_type_declaration) by default. This is especially notable since many HTML documents start with ``, and `roxmltree` should be able to parse some simple HTML documents. The security concerns with DTDs are [XXE attacks](https://en.wikipedia.org/wiki/XML_external_entity_attack), and [exponential entity expansion attacks](https://en.wikipedia.org/wiki/Billion_laughs_attack). `roxmltree` [doesn't support](https://github.com/RazrFalcon/roxmltree/blob/d2c7801624757d14f83ba543484479bcd56c3251/src/tokenizer.rs#L535-L547) external entities (it parses them, but doesn't do anything with them), so it is not vulnerable to XXE attacks. Additionally, `roxmltree` has [some safeguards](https://github.com/RazrFalcon/roxmltree/blob/d2c7801624757d14f83ba543484479bcd56c3251/src/parse.rs#L424-L452) in place to prevent exponential entity expansion, so enabling DTDs by default is relatively safe. The worst case is no worse than running `loop {}`, so I think allowing DTDs by default is best, and DTDs can still be disabled with `--disallow-dtd` if needed. # User-Facing Changes * Allows `from xml` to parse XML documents with [document type declarations](https://en.wikipedia.org/wiki/Document_type_declaration) by default, and adds a `--disallow-dtd` flag to disallow parsing documents with DTDs. This PR also improves the errors in `from xml` by pointing at the issue in the XML source. Example: ``` $ open --raw foo.xml | from xml Error: × Failed to parse XML ╭─[2:7] 1 │ 2 │ hi

· ▲ · ╰── Unexpected character <, expected a whitespace 3 │ ╰──── ``` # Tests + Formatting N/A # After Submitting N/A --- .../src/env/config/config_flatten.rs | 22 +-- crates/nu-command/src/formats/from/json.rs | 24 +-- crates/nu-command/src/formats/from/xml.rs | 163 +++++++++++------- crates/nu-protocol/src/span.rs | 22 +++ 4 files changed, 123 insertions(+), 108 deletions(-) diff --git a/crates/nu-command/src/env/config/config_flatten.rs b/crates/nu-command/src/env/config/config_flatten.rs index ee41897466..c720b27f70 100644 --- a/crates/nu-command/src/env/config/config_flatten.rs +++ b/crates/nu-command/src/env/config/config_flatten.rs @@ -72,7 +72,7 @@ fn convert_string_to_value( Err(x) => match x { nu_json::Error::Syntax(_, row, col) => { let label = x.to_string(); - let label_span = convert_row_column_to_span(row, col, string_input); + let label_span = Span::from_row_column(row, col, string_input); Err(ShellError::GenericError { error: "Error while parsing JSON text".into(), msg: "error parsing JSON text".into(), @@ -173,23 +173,3 @@ fn expand_closure( _ => None, } } - -// Converts row+column to a Span, assuming bytes (1-based rows) -fn convert_row_column_to_span(row: usize, col: usize, contents: &str) -> Span { - let mut cur_row = 1; - let mut cur_col = 1; - - for (offset, curr_byte) in contents.bytes().enumerate() { - if curr_byte == b'\n' { - cur_row += 1; - cur_col = 1; - } - if cur_row >= row && cur_col >= col { - return Span::new(offset, offset); - } else { - cur_col += 1; - } - } - - Span::new(contents.len(), contents.len()) -} diff --git a/crates/nu-command/src/formats/from/json.rs b/crates/nu-command/src/formats/from/json.rs index 17a632d949..81a8175cca 100644 --- a/crates/nu-command/src/formats/from/json.rs +++ b/crates/nu-command/src/formats/from/json.rs @@ -184,26 +184,6 @@ fn convert_nujson_to_value(value: nu_json::Value, span: Span) -> Value { } } -// Converts row+column to a Span, assuming bytes (1-based rows) -fn convert_row_column_to_span(row: usize, col: usize, contents: &str) -> Span { - let mut cur_row = 1; - let mut cur_col = 1; - - for (offset, curr_byte) in contents.bytes().enumerate() { - if curr_byte == b'\n' { - cur_row += 1; - cur_col = 1; - } - if cur_row >= row && cur_col >= col { - return Span::new(offset, offset); - } else { - cur_col += 1; - } - } - - Span::new(contents.len(), contents.len()) -} - fn convert_string_to_value(string_input: &str, span: Span) -> Result { match nu_json::from_str(string_input) { Ok(value) => Ok(convert_nujson_to_value(value, span)), @@ -211,7 +191,7 @@ fn convert_string_to_value(string_input: &str, span: Span) -> Result match x { nu_json::Error::Syntax(_, row, col) => { let label = x.to_string(); - let label_span = convert_row_column_to_span(row, col, string_input); + let label_span = Span::from_row_column(row, col, string_input); Err(ShellError::GenericError { error: "Error while parsing JSON text".into(), msg: "error parsing JSON text".into(), @@ -240,7 +220,7 @@ fn convert_string_to_value_strict(string_input: &str, span: Span) -> Result Ok(convert_nujson_to_value(value, span)), Err(err) => Err(if err.is_syntax() { let label = err.to_string(); - let label_span = convert_row_column_to_span(err.line(), err.column(), string_input); + let label_span = Span::from_row_column(err.line(), err.column(), string_input); ShellError::GenericError { error: "Error while parsing JSON text".into(), msg: "error parsing JSON text".into(), diff --git a/crates/nu-command/src/formats/from/xml.rs b/crates/nu-command/src/formats/from/xml.rs index 70c1048972..0c63d97c93 100644 --- a/crates/nu-command/src/formats/from/xml.rs +++ b/crates/nu-command/src/formats/from/xml.rs @@ -2,7 +2,7 @@ use crate::formats::nu_xml_format::{COLUMN_ATTRS_NAME, COLUMN_CONTENT_NAME, COLU use indexmap::IndexMap; use nu_engine::command_prelude::*; -use roxmltree::NodeType; +use roxmltree::{NodeType, ParsingOptions, TextPos}; #[derive(Clone)] pub struct FromXml; @@ -16,6 +16,11 @@ impl Command for FromXml { Signature::build("from xml") .input_output_types(vec![(Type::String, Type::record())]) .switch("keep-comments", "add comment nodes to result", None) + .switch( + "disallow-dtd", + "disallow parsing documents with DTDs (prevents exponential entity expansion attacks)", + None, + ) .switch( "keep-pi", "add processing instruction nodes to result", @@ -50,10 +55,12 @@ string. This way content of every tag is always a table and is easier to parse"# let head = call.head; let keep_comments = call.has_flag(engine_state, stack, "keep-comments")?; let keep_processing_instructions = call.has_flag(engine_state, stack, "keep-pi")?; + let allow_dtd = !call.has_flag(engine_state, stack, "disallow-dtd")?; let info = ParsingInfo { span: head, keep_comments, keep_processing_instructions, + allow_dtd, }; from_xml(input, &info) } @@ -90,6 +97,7 @@ struct ParsingInfo { span: Span, keep_comments: bool, keep_processing_instructions: bool, + allow_dtd: bool, } fn from_attributes_to_value(attributes: &[roxmltree::Attribute], info: &ParsingInfo) -> Value { @@ -198,7 +206,12 @@ fn from_document_to_value(d: &roxmltree::Document, info: &ParsingInfo) -> Value } fn from_xml_string_to_value(s: &str, info: &ParsingInfo) -> Result { - let parsed = roxmltree::Document::parse(s)?; + let options = ParsingOptions { + allow_dtd: info.allow_dtd, + ..Default::default() + }; + + let parsed = roxmltree::Document::parse_with_options(s, options)?; Ok(from_document_to_value(&parsed, info)) } @@ -209,116 +222,135 @@ fn from_xml(input: PipelineData, info: &ParsingInfo) -> Result { Ok(x.into_pipeline_data_with_metadata(metadata.map(|md| md.with_content_type(None)))) } - Err(err) => Err(process_xml_parse_error(err, span)), + Err(err) => Err(process_xml_parse_error(concat_string, err, span)), } } -fn process_xml_parse_error(err: roxmltree::Error, span: Span) -> ShellError { +fn process_xml_parse_error(source: String, err: roxmltree::Error, span: Span) -> ShellError { match err { - roxmltree::Error::InvalidXmlPrefixUri(_) => make_cant_convert_error( + roxmltree::Error::InvalidXmlPrefixUri(pos) => make_xml_error_spanned( "The `xmlns:xml` attribute must have an URI.", - span, + source, pos, ), - roxmltree::Error::UnexpectedXmlUri(_) => make_cant_convert_error( + roxmltree::Error::UnexpectedXmlUri(pos) => make_xml_error_spanned( "Only the xmlns:xml attribute can have the http://www.w3.org/XML/1998/namespace URI.", - span, + source, pos, ), - roxmltree::Error::UnexpectedXmlnsUri(_) => make_cant_convert_error( + roxmltree::Error::UnexpectedXmlnsUri(pos) => make_xml_error_spanned( "The http://www.w3.org/2000/xmlns/ URI must not be declared.", - span, + source, pos, ), - roxmltree::Error::InvalidElementNamePrefix(_) => { - make_cant_convert_error("xmlns can't be used as an element prefix.", span) + roxmltree::Error::InvalidElementNamePrefix(pos) => { + make_xml_error_spanned("xmlns can't be used as an element prefix.", source, pos) } - roxmltree::Error::DuplicatedNamespace(_, _) => { - make_cant_convert_error("A namespace was already defined on this element.", span) + roxmltree::Error::DuplicatedNamespace(namespace, pos) => { + make_xml_error_spanned(format!("Namespace {namespace} was already defined on this element."), source, pos) } - roxmltree::Error::UnknownNamespace(prefix, _) => { - make_cant_convert_error(format!("Unknown prefix {}", prefix), span) + roxmltree::Error::UnknownNamespace(prefix, pos) => { + make_xml_error_spanned(format!("Unknown prefix {}", prefix), source, pos) } - roxmltree::Error::UnexpectedCloseTag { .. } => { - make_cant_convert_error("Unexpected close tag", span) + roxmltree::Error::UnexpectedCloseTag(expected, actual, pos) => { + make_xml_error_spanned(format!("Unexpected close tag {actual}, expected {expected}"), source, pos) } - roxmltree::Error::UnexpectedEntityCloseTag(_) => { - make_cant_convert_error("Entity value starts with a close tag.", span) + roxmltree::Error::UnexpectedEntityCloseTag(pos) => { + make_xml_error_spanned("Entity value starts with a close tag.", source, pos) } - roxmltree::Error::UnknownEntityReference(_, _) => make_cant_convert_error( - "A reference to an entity that was not defined in the DTD.", - span, + roxmltree::Error::UnknownEntityReference(entity, pos) => make_xml_error_spanned( + format!("Reference to unknown entity {entity} (was not defined in the DTD)"), + source, pos, ), - roxmltree::Error::MalformedEntityReference(_) => { - make_cant_convert_error("A malformed entity reference.", span) + roxmltree::Error::MalformedEntityReference(pos) => { + make_xml_error_spanned("Malformed entity reference.", source, pos) } - roxmltree::Error::EntityReferenceLoop(_) => { - make_cant_convert_error("A possible entity reference loop.", span) + roxmltree::Error::EntityReferenceLoop(pos) => { + make_xml_error_spanned("Possible entity reference loop.", source, pos) } - roxmltree::Error::InvalidAttributeValue(_) => { - make_cant_convert_error("Attribute value cannot have a < character.", span) + roxmltree::Error::InvalidAttributeValue(pos) => { + make_xml_error_spanned("Attribute value cannot have a < character.", source, pos) } - roxmltree::Error::DuplicatedAttribute(_, _) => { - make_cant_convert_error("An element has a duplicated attributes.", span) + roxmltree::Error::DuplicatedAttribute(attribute, pos) => { + make_xml_error_spanned(format!("Element has a duplicated attribute: {attribute}"), source, pos) } roxmltree::Error::NoRootNode => { - make_cant_convert_error("The XML document must have at least one element.", span) + make_xml_error("The XML document must have at least one element.", span) } roxmltree::Error::UnclosedRootNode => { - make_cant_convert_error("The root node was opened but never closed.", span) + make_xml_error("The root node was opened but never closed.", span) } - roxmltree::Error::DtdDetected => make_cant_convert_error( - "An XML with DTD detected. DTDs are currently disabled due to security reasons.", - span, + roxmltree::Error::DtdDetected => make_xml_error( + "XML document with DTD detected.", + span ), roxmltree::Error::NodesLimitReached => { - make_cant_convert_error("Node limit was reached.", span) + make_xml_error("Node limit was reached.", span) } roxmltree::Error::AttributesLimitReached => { - make_cant_convert_error("Attribute limit reached", span) + make_xml_error("Attribute limit reached", span) } roxmltree::Error::NamespacesLimitReached => { - make_cant_convert_error("Namespace limit reached", span) + make_xml_error("Namespace limit reached", span) } - roxmltree::Error::UnexpectedDeclaration(_) => { - make_cant_convert_error("An XML document can have only one XML declaration and it must be at the start of the document.", span) + roxmltree::Error::UnexpectedDeclaration(pos) => { + make_xml_error_spanned("An XML document can have only one XML declaration and it must be at the start of the document.", source, pos) } - roxmltree::Error::InvalidName(_) => { - make_cant_convert_error("Invalid name found.", span) + roxmltree::Error::InvalidName(pos) => { + make_xml_error_spanned("Invalid name.", source, pos) } - roxmltree::Error::NonXmlChar(_, _) => { - make_cant_convert_error("A non-XML character has occurred. Valid characters are: ", span) + roxmltree::Error::NonXmlChar(_, pos) => { + make_xml_error_spanned("Non-XML character found. Valid characters are: ", source, pos) } - roxmltree::Error::InvalidChar(_, _, _) => { - make_cant_convert_error("An invalid/unexpected character in XML.", span) + roxmltree::Error::InvalidChar(expected, actual, pos) => { + make_xml_error_spanned( + format!("Unexpected character {}, expected {}", actual as char, expected as char), + source, + pos + ) } - roxmltree::Error::InvalidChar2(_, _, _) => { - make_cant_convert_error("An invalid/unexpected character in XML.", span) + roxmltree::Error::InvalidChar2(expected, actual, pos) => { + make_xml_error_spanned( + format!("Unexpected character {}, expected {}", actual as char, expected), + source, + pos + ) } - roxmltree::Error::InvalidString(_, _) => { - make_cant_convert_error("An invalid/unexpected string in XML.", span) + roxmltree::Error::InvalidString(_, pos) => { + make_xml_error_spanned("Invalid/unexpected string in XML.", source, pos) } - roxmltree::Error::InvalidExternalID(_) => { - make_cant_convert_error("An invalid ExternalID in the DTD.", span) + roxmltree::Error::InvalidExternalID(pos) => { + make_xml_error_spanned("Invalid ExternalID in the DTD.", source, pos) } - roxmltree::Error::InvalidComment(_) => { - make_cant_convert_error("A comment cannot contain `--` or end with `-`.", span) + roxmltree::Error::InvalidComment(pos) => { + make_xml_error_spanned("A comment cannot contain `--` or end with `-`.", source, pos) } - roxmltree::Error::InvalidCharacterData(_) => { - make_cant_convert_error("A Character Data node contains an invalid data. Currently, only `]]>` is not allowed.", span) + roxmltree::Error::InvalidCharacterData(pos) => { + make_xml_error_spanned("Character Data node contains an invalid data. Currently, only `]]>` is not allowed.", source, pos) } - roxmltree::Error::UnknownToken(_) => { - make_cant_convert_error("Unknown token in XML.", span) + roxmltree::Error::UnknownToken(pos) => { + make_xml_error_spanned("Unknown token in XML.", source, pos) } roxmltree::Error::UnexpectedEndOfStream => { - make_cant_convert_error("Unexpected end of stream while parsing XML.", span) + make_xml_error("Unexpected end of stream while parsing XML.", span) } } } -fn make_cant_convert_error(help: impl Into, span: Span) -> ShellError { - ShellError::CantConvert { - from_type: Type::String.to_string(), - to_type: "XML".to_string(), +fn make_xml_error(msg: impl Into, span: Span) -> ShellError { + ShellError::GenericError { + error: "Failed to parse XML".into(), + msg: msg.into(), + help: None, + span: Some(span), + inner: vec![], + } +} + +fn make_xml_error_spanned(msg: impl Into, src: String, pos: TextPos) -> ShellError { + let span = Span::from_row_column(pos.row as usize, pos.col as usize, &src); + ShellError::OutsideSpannedLabeledError { + src, + error: "Failed to parse XML".into(), + msg: msg.into(), span, - help: Some(help.into()), } } @@ -375,6 +407,7 @@ mod tests { span: Span::test_data(), keep_comments: false, keep_processing_instructions: false, + allow_dtd: false, }; from_xml_string_to_value(xml, &info) } diff --git a/crates/nu-protocol/src/span.rs b/crates/nu-protocol/src/span.rs index 77e5bab681..7eeaffe04b 100644 --- a/crates/nu-protocol/src/span.rs +++ b/crates/nu-protocol/src/span.rs @@ -148,6 +148,28 @@ impl Span { } } + /// Converts row and column in a String to a Span, assuming bytes (1-based rows) + pub fn from_row_column(row: usize, col: usize, contents: &str) -> Span { + let mut cur_row = 1; + let mut cur_col = 1; + + for (offset, curr_byte) in contents.bytes().enumerate() { + if curr_byte == b'\n' { + cur_row += 1; + cur_col = 1; + } else if cur_row >= row && cur_col >= col { + return Span::new(offset, offset); + } else { + cur_col += 1; + } + } + + Self { + start: contents.len(), + end: contents.len(), + } + } + /// Returns the minimal [`Span`] that encompasses both of the given spans. /// /// The two `Spans` can overlap in the middle, From a17ffdfe5674d87b9a43d7d1c0ed616fd42174df Mon Sep 17 00:00:00 2001 From: Yash Thakur <45539777+ysthakur@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:13:41 -0400 Subject: [PATCH 09/59] Include symlinks in directory completions (#15268) Fixes #15077 # Description Symlinks are currently not shown in directory completions. #14667 modified completions so that symlinks wouldn't be suggested with trailing slashes, but it did this by treating symlinks as files. This PR includes symlinks to directories when completing directories, but still suggests them without trailing slashes. # User-Facing Changes Directory completions will once again include symlinks. # Tests + Formatting # After Submitting --- .../src/completions/completion_common.rs | 5 +++-- crates/nu-cli/tests/completions/mod.rs | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index f5adb6aecd..31a4bdd75b 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -65,10 +65,11 @@ fn complete_rec( for entry in result.filter_map(|e| e.ok()) { let entry_name = entry.file_name().to_string_lossy().into_owned(); - let entry_isdir = entry.path().is_dir() && !entry.path().is_symlink(); + let entry_isdir = entry.path().is_dir(); let mut built = built.clone(); built.parts.push(entry_name.clone()); - built.isdir = entry_isdir; + // Symlinks to directories shouldn't have a trailing slash (#13275) + built.isdir = entry_isdir && !entry.path().is_symlink(); if !want_directory || entry_isdir { matcher.add(entry_name.clone(), (entry_name, built)); diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index 8c29c83ebc..5890aa21da 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -307,7 +307,12 @@ fn custom_arguments_and_subcommands() { let completion_str = "foo test"; let suggestions = completer.complete(completion_str, completion_str.len()); // including both subcommand and directory completions - let expected = ["foo test bar".into(), folder("test_a"), folder("test_b")]; + let expected = [ + "foo test bar".into(), + folder("test_a"), + file("test_a_symlink"), + folder("test_b"), + ]; match_suggestions_by_string(&expected, &suggestions); } @@ -1492,6 +1497,7 @@ fn folder_with_directorycompletions() { folder(dir.join("another")), folder(dir.join("directory_completion")), folder(dir.join("test_a")), + file(dir.join("test_a_symlink")), folder(dir.join("test_b")), folder(dir.join(".hidden_folder")), ]; @@ -1594,6 +1600,12 @@ fn folder_with_directorycompletions_with_three_trailing_dots() { .join("...") .join("test_a"), ), + file( + dir.join("directory_completion") + .join("folder_inside_folder") + .join("...") + .join("test_a_symlink"), + ), folder( dir.join("directory_completion") .join("folder_inside_folder") @@ -1666,6 +1678,13 @@ fn folder_with_directorycompletions_do_not_collapse_dots() { .join("..") .join("test_a"), ), + file( + dir.join("directory_completion") + .join("folder_inside_folder") + .join("..") + .join("..") + .join("test_a_symlink"), + ), folder( dir.join("directory_completion") .join("folder_inside_folder") From 44b7cfd6968fb49d78826836340ba83cd4cbb7b6 Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 12 Mar 2025 21:48:19 +0800 Subject: [PATCH 10/59] refactor: tree-sitter-nu friendly alternative expressions (#15301) # Description Choose more tree-sitter-nu-friendly (if not better) expressions in nu scripts. The changes made in this PR all come from known issues of `tree-sitter-nu`. 1. nested single/double quotes: https://github.com/nushell/tree-sitter-nu/issues/125 2. module path of `use` command: https://github.com/nushell/tree-sitter-nu/issues/165 3. where predicates of boolean column: https://github.com/nushell/tree-sitter-nu/issues/177 4. `error make` keyword: https://github.com/nushell/tree-sitter-nu/issues/179 Those issues are either hard to fix or "not planned" for syntactical precision considerations ATM. # User-Facing Changes Should be none # Tests + Formatting # After Submitting --- crates/nu-std/std-rfc/tables/mod.nu | 6 +++--- crates/nu-std/std/help/mod.nu | 6 +++--- scripts/build-all.nu | 2 +- scripts/coverage-local.nu | 2 +- scripts/test_virtualenv.nu | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/nu-std/std-rfc/tables/mod.nu b/crates/nu-std/std-rfc/tables/mod.nu index 96a5e11845..f775e6df2c 100644 --- a/crates/nu-std/std-rfc/tables/mod.nu +++ b/crates/nu-std/std-rfc/tables/mod.nu @@ -55,7 +55,7 @@ export def aggregate [ } } - def "error not-a-table" [span: record] { + def "error-make not-a-table" [span: record] { error make { msg: "input must be a table", label: { @@ -69,9 +69,9 @@ export def aggregate [ let IN = $in let md = metadata $in - let first = try { $IN | first } catch { error not-a-table $md.span } + let first = try { $IN | first } catch { error-make not-a-table $md.span } if not (($first | describe) starts-with record) { - error not-a-table $md.span + error-make not-a-table $md.span } let grouped = "items" in $first diff --git a/crates/nu-std/std/help/mod.nu b/crates/nu-std/std/help/mod.nu index c57decbb15..fcdcc67a35 100644 --- a/crates/nu-std/std/help/mod.nu +++ b/crates/nu-std/std/help/mod.nu @@ -109,7 +109,7 @@ def "nu-complete main-help" [] { } def "nu-complete list-externs" [] { - scope commands | where is_extern | select name description | rename value description + scope commands | where is_extern == true | select name description | rename value description } def build-help-header [ @@ -397,7 +397,7 @@ export def externs [ ] { let externs = ( scope commands - | where is_extern + | where is_extern == true | select name module_name description | sort-by name | str trim @@ -761,7 +761,7 @@ Here are some tips to help you get started. * ('help ' | pretty-cmd) - display help about a particular command, alias, or module * ('help --find ' | pretty-cmd) - search through all help commands table -Nushell works on the idea of a "(ansi default_italic)pipeline(ansi reset)". Pipelines are commands connected with the '|' character. +Nushell works on the idea of a '(ansi default_italic)pipeline(ansi reset)'. Pipelines are commands connected with the '|' character. Each stage in the pipeline works together to load, parse, and display information to you. (ansi green)Examples(ansi reset): diff --git a/scripts/build-all.nu b/scripts/build-all.nu index a340dbae70..de0ab15003 100644 --- a/scripts/build-all.nu +++ b/scripts/build-all.nu @@ -1,4 +1,4 @@ -use std log warning +use std/log warning print '-------------------------------------------------------------------' print 'Building nushell (nu) and all the plugins' diff --git a/scripts/coverage-local.nu b/scripts/coverage-local.nu index 0a2c017bd6..63c1cf0924 100755 --- a/scripts/coverage-local.nu +++ b/scripts/coverage-local.nu @@ -1,5 +1,5 @@ #!/usr/bin/env nu -use std log warning +use std/log warning warning "./scripts/coverage-local.nu will be deprecated, please use the `toolkit cov` command instead" diff --git a/scripts/test_virtualenv.nu b/scripts/test_virtualenv.nu index dec6a8fbdf..fc86b81ac3 100644 --- a/scripts/test_virtualenv.nu +++ b/scripts/test_virtualenv.nu @@ -19,14 +19,14 @@ let exe = $paths.1 let test_lines = [ "python -c 'import sys; print(sys.executable)'" # 1 - "python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'" # 2 + `python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'` # 2 $"overlay use '([$env.PWD $env_name $subdir activate.nu] | path join)'" "python -c 'import sys; print(sys.executable)'" # 3 - "python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'" # 4 + `python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'` # 4 "print $env.VIRTUAL_ENV_PROMPT" # 5 "deactivate" "python -c 'import sys; print(sys.executable)'" # 6 - "python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'" # 7 + `python -c 'import os; import sys; v = os.environ.get("VIRTUAL_ENV"); print(v)'` # 7 ] def main [] { From 966cebec3496d8c3b7b87c21288521cfd8d34534 Mon Sep 17 00:00:00 2001 From: Matthias Meschede Date: Wed, 12 Mar 2025 16:25:03 +0100 Subject: [PATCH 11/59] Adds polars list-contains command (#15304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR adds the `polars list-contains` command. It works like this: ``` ~/Projects/nushell/nushell> let df = [[a]; [[a,b,c]] [[b,c,d]] [[c,d,f]]] | polars into-df -s {a: list}; ~/Projects/nushell/nushell> $df | polars with-column [(polars col a | polars list-contains (polars lit a) | polars as b)] | polars collect ╭───┬───────────┬───────╮ │ # │ a │ b │ ├───┼───────────┼───────┤ │ 0 │ ╭───┬───╮ │ true │ │ │ │ 0 │ a │ │ │ │ │ │ 1 │ b │ │ │ │ │ │ 2 │ c │ │ │ │ │ ╰───┴───╯ │ │ │ 1 │ ╭───┬───╮ │ false │ │ │ │ 0 │ b │ │ │ │ │ │ 1 │ c │ │ │ │ │ │ 2 │ d │ │ │ │ │ ╰───┴───╯ │ │ │ 2 │ ╭───┬───╮ │ false │ │ │ │ 0 │ c │ │ │ │ │ │ 1 │ d │ │ │ │ │ │ 2 │ f │ │ │ │ │ ╰───┴───╯ │ │ ╰───┴───────────┴───────╯ ``` or ``` ~/Projects/nushell/nushell> let df = [[a, b]; [[a,b,c], a] [[b,c,d], f] [[c,d,f], f]] | polars into-df -s {a: list, b: str} ~/Projects/nushell/nushell> $df | polars with-column [(polars col a | polars list-contains b | polars as c)] | polars collect ╭───┬───────────┬───┬───────╮ │ # │ a │ b │ c │ ├───┼───────────┼───┼───────┤ │ 0 │ ╭───┬───╮ │ a │ true │ │ │ │ 0 │ a │ │ │ │ │ │ │ 1 │ b │ │ │ │ │ │ │ 2 │ c │ │ │ │ │ │ ╰───┴───╯ │ │ │ │ 1 │ ╭───┬───╮ │ f │ false │ │ │ │ 0 │ b │ │ │ │ │ │ │ 1 │ c │ │ │ │ │ │ │ 2 │ d │ │ │ │ │ │ ╰───┴───╯ │ │ │ │ 2 │ ╭───┬───╮ │ f │ true │ │ │ │ 0 │ c │ │ │ │ │ │ │ 1 │ d │ │ │ │ │ │ │ 2 │ f │ │ │ │ │ │ ╰───┴───╯ │ │ │ ╰───┴───────────┴───┴───────╯ ``` or ``` ~/Projects/nushell/nushell> let df = [[a, b]; [[1,2,3], 4] [[2,4,1], 2] [[2,1,6], 3]] | polars into-df -s {a: list, b: i64} ~/Projects/nushell/nushell> $df | polars with-column [(polars col a | polars list-contains ((polars col b) * 2) | polars as c)] | polars collect ╭───┬───────────┬───┬───────╮ │ # │ a │ b │ c │ ├───┼───────────┼───┼───────┤ │ 0 │ ╭───┬───╮ │ 4 │ false │ │ │ │ 0 │ 1 │ │ │ │ │ │ │ 1 │ 2 │ │ │ │ │ │ │ 2 │ 3 │ │ │ │ │ │ ╰───┴───╯ │ │ │ │ 1 │ ╭───┬───╮ │ 2 │ true │ │ │ │ 0 │ 2 │ │ │ │ │ │ │ 1 │ 4 │ │ │ │ │ │ │ 2 │ 1 │ │ │ │ │ │ ╰───┴───╯ │ │ │ │ 2 │ ╭───┬───╮ │ 3 │ true │ │ │ │ 0 │ 2 │ │ │ │ │ │ │ 1 │ 1 │ │ │ │ │ │ │ 2 │ 6 │ │ │ │ │ │ ╰───┴───╯ │ │ │ ╰───┴───────────┴───┴───────╯ ``` Let me know what you think. I'm a bit surprised that a list by default seems to get converted to "object" when doing `into-df` which is why I added the extra `-s` flag every time to explicitly force it into a list. --- .../src/dataframe/command/list/contains.rs | 161 ++++++++++++++++++ .../src/dataframe/command/list/mod.rs | 10 ++ .../src/dataframe/command/mod.rs | 1 + crates/nu_plugin_polars/src/lib.rs | 3 +- 4 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 crates/nu_plugin_polars/src/dataframe/command/list/contains.rs create mode 100644 crates/nu_plugin_polars/src/dataframe/command/list/mod.rs diff --git a/crates/nu_plugin_polars/src/dataframe/command/list/contains.rs b/crates/nu_plugin_polars/src/dataframe/command/list/contains.rs new file mode 100644 index 0000000000..16902541c8 --- /dev/null +++ b/crates/nu_plugin_polars/src/dataframe/command/list/contains.rs @@ -0,0 +1,161 @@ +use crate::{ + values::{ + cant_convert_err, CustomValueSupport, NuExpression, PolarsPluginObject, PolarsPluginType, + }, + PolarsPlugin, +}; + +use super::super::super::values::{Column, NuDataFrame}; + +use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand}; +use nu_protocol::{ + Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, + Value, +}; + +#[derive(Clone)] +pub struct ListContains; + +impl PluginCommand for ListContains { + type Plugin = PolarsPlugin; + + fn name(&self) -> &str { + "polars list-contains" + } + + fn description(&self) -> &str { + "Checks if an element is contained in a list." + } + + fn signature(&self) -> Signature { + Signature::build(self.name()) + .required( + "element", + SyntaxShape::Any, + "Element to search for in the list", + ) + .input_output_types(vec![( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + )]) + .category(Category::Custom("dataframe".into())) + } + + fn examples(&self) -> Vec { + vec![ + Example { + description: "Returns boolean indicating if a literal element was found in a list column", + example: "let df = [[a]; [[a,b,c]] [[b,c,d]] [[c,d,f]]] | polars into-df -s {a: list}; + let df2 = $df | polars with-column [(polars col a | polars list-contains (polars lit a) | polars as b)] | polars collect; + $df2.b", + result: Some( + NuDataFrame::try_from_columns( + vec![Column::new( + "b".to_string(), + vec![ + Value::test_bool(true), + Value::test_bool(false), + Value::test_bool(false), + ], + )], + None, + ) + .expect("simple df for test should not fail") + .into_value(Span::test_data()), + ), + }, + Example { + description: "Returns boolean indicating if an element from another column was found in a list column", + example: "let df = [[a, b]; [[a,b,c], a] [[b,c,d], f] [[c,d,f], f]] | polars into-df -s {a: list, b: str}; + let df2 = $df | polars with-column [(polars col a | polars list-contains b | polars as c)] | polars collect; + $df2.c", + result: Some( + NuDataFrame::try_from_columns( + vec![Column::new( + "b".to_string(), + vec![ + Value::test_bool(true), + Value::test_bool(false), + Value::test_bool(true), + ], + )], + None, + ) + .expect("simple df for test should not fail") + .into_value(Span::test_data()), + ), + }, + Example { + description: "Returns boolean indicating if an element from another expression was found in a list column", + example: "let df = [[a, b]; [[1,2,3], 4] [[2,4,1], 2] [[2,1,6], 3]] | polars into-df -s {a: list, b: i64}; + let df2 = $df | polars with-column [(polars col a | polars list-contains ((polars col b) * 2) | polars as c)] | polars collect; + $df2.c", + result: Some( + NuDataFrame::try_from_columns( + vec![Column::new( + "b".to_string(), + vec![ + Value::test_bool(false), + Value::test_bool(true), + Value::test_bool(true), + ], + )], + None, + ) + .expect("simple df for test should not fail") + .into_value(Span::test_data()), + ), + } + ] + } + + fn run( + &self, + plugin: &Self::Plugin, + engine: &EngineInterface, + call: &EvaluatedCall, + input: PipelineData, + ) -> Result { + let value = input.into_value(call.head)?; + match PolarsPluginObject::try_from_value(plugin, &value)? { + PolarsPluginObject::NuExpression(expr) => command_expr(plugin, engine, call, expr), + _ => Err(cant_convert_err(&value, &[PolarsPluginType::NuExpression])), + } + .map_err(LabeledError::from) + } +} + +fn command_expr( + plugin: &PolarsPlugin, + engine: &EngineInterface, + call: &EvaluatedCall, + expr: NuExpression, +) -> Result { + let element = call.req(0)?; + let expressions = NuExpression::extract_exprs(plugin, element)?; + let single_expression = match expressions.as_slice() { + [single] => single.clone(), + _ => { + return Err(ShellError::GenericError { + error: "Expected a single polars expression".into(), + msg: "Requires a single polars expressions or column name as argument".into(), + span: Some(call.head), + help: None, + inner: vec![], + }) + } + }; + let res: NuExpression = expr.into_polars().list().contains(single_expression).into(); + res.to_pipeline_data(plugin, engine, call.head) +} + +#[cfg(test)] +mod test { + use super::*; + use crate::test::test_polars_plugin_command; + + #[test] + fn test_examples() -> Result<(), ShellError> { + test_polars_plugin_command(&ListContains) + } +} diff --git a/crates/nu_plugin_polars/src/dataframe/command/list/mod.rs b/crates/nu_plugin_polars/src/dataframe/command/list/mod.rs new file mode 100644 index 0000000000..ea90505a9a --- /dev/null +++ b/crates/nu_plugin_polars/src/dataframe/command/list/mod.rs @@ -0,0 +1,10 @@ +mod contains; + +use crate::PolarsPlugin; +use nu_plugin::PluginCommand; + +pub use contains::ListContains; + +pub(crate) fn list_commands() -> Vec>> { + vec![Box::new(ListContains)] +} diff --git a/crates/nu_plugin_polars/src/dataframe/command/mod.rs b/crates/nu_plugin_polars/src/dataframe/command/mod.rs index 50c0d522a1..c439411b75 100644 --- a/crates/nu_plugin_polars/src/dataframe/command/mod.rs +++ b/crates/nu_plugin_polars/src/dataframe/command/mod.rs @@ -5,5 +5,6 @@ pub mod data; pub mod datetime; pub mod index; pub mod integer; +pub mod list; pub mod string; pub mod stub; diff --git a/crates/nu_plugin_polars/src/lib.rs b/crates/nu_plugin_polars/src/lib.rs index d9c7e6d392..f497f59567 100644 --- a/crates/nu_plugin_polars/src/lib.rs +++ b/crates/nu_plugin_polars/src/lib.rs @@ -8,7 +8,7 @@ pub use cache::{Cache, Cacheable}; use command::{ aggregation::aggregation_commands, boolean::boolean_commands, core::core_commands, data::data_commands, datetime::datetime_commands, index::index_commands, - integer::integer_commands, string::string_commands, stub::PolarsCmd, + integer::integer_commands, list::list_commands, string::string_commands, stub::PolarsCmd, }; use log::debug; use nu_plugin::{EngineInterface, Plugin, PluginCommand}; @@ -93,6 +93,7 @@ impl Plugin for PolarsPlugin { commands.append(&mut index_commands()); commands.append(&mut integer_commands()); commands.append(&mut string_commands()); + commands.append(&mut list_commands()); commands.append(&mut cache_commands()); commands From 03888b9d81d5204682216760c4dae6500f693940 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 12 Mar 2025 21:42:49 +0100 Subject: [PATCH 12/59] Remove `range` command after deprecation (#15038) # Description Follow up to https://github.com/nushell/nushell/pull/14825 # User-Facing Changes `range` is gone for good. Use `slice` as a one-for-one replacement. --- crates/nu-command/src/default_context.rs | 1 - crates/nu-command/src/filters/mod.rs | 2 - crates/nu-command/src/filters/range.rs | 90 ------------------------ 3 files changed, 93 deletions(-) delete mode 100644 crates/nu-command/src/filters/range.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index da6d62289c..dfd7badbec 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -70,7 +70,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { ParEach, ChunkBy, Prepend, - Range, Reduce, Reject, Rename, diff --git a/crates/nu-command/src/filters/mod.rs b/crates/nu-command/src/filters/mod.rs index ed1e9d8614..6eaaaea860 100644 --- a/crates/nu-command/src/filters/mod.rs +++ b/crates/nu-command/src/filters/mod.rs @@ -31,7 +31,6 @@ mod merge; mod move_; mod par_each; mod prepend; -mod range; mod reduce; mod reject; mod rename; @@ -91,7 +90,6 @@ pub use merge::MergeDeep; pub use move_::Move; pub use par_each::ParEach; pub use prepend::Prepend; -pub use range::Range; pub use reduce::Reduce; pub use reject::Reject; pub use rename::Rename; diff --git a/crates/nu-command/src/filters/range.rs b/crates/nu-command/src/filters/range.rs deleted file mode 100644 index 74ca8e1186..0000000000 --- a/crates/nu-command/src/filters/range.rs +++ /dev/null @@ -1,90 +0,0 @@ -use nu_engine::command_prelude::*; -use nu_protocol::{report_parse_warning, ParseWarning}; - -#[derive(Clone)] -pub struct Range; - -impl Command for Range { - fn name(&self) -> &str { - "range" - } - - fn signature(&self) -> Signature { - Signature::build("range") - .input_output_types(vec![( - Type::List(Box::new(Type::Any)), - Type::List(Box::new(Type::Any)), - )]) - .required("rows", SyntaxShape::Range, "Range of rows to return.") - .category(Category::Deprecated) - } - - fn description(&self) -> &str { - "Return only the selected rows." - } - - fn search_terms(&self) -> Vec<&str> { - vec!["filter", "head", "tail", "slice"] - } - - fn examples(&self) -> Vec { - vec![ - Example { - example: "[0,1,2,3,4,5] | range 4..5", - description: "Get the last 2 items", - result: Some(Value::list( - vec![Value::test_int(4), Value::test_int(5)], - Span::test_data(), - )), - }, - Example { - example: "[0,1,2,3,4,5] | range (-2)..", - description: "Get the last 2 items", - result: Some(Value::list( - vec![Value::test_int(4), Value::test_int(5)], - Span::test_data(), - )), - }, - Example { - example: "[0,1,2,3,4,5] | range (-3)..-2", - description: "Get the next to last 2 items", - result: Some(Value::list( - vec![Value::test_int(3), Value::test_int(4)], - Span::test_data(), - )), - }, - ] - } - - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - let head = call.head; - report_parse_warning( - &StateWorkingSet::new(engine_state), - &ParseWarning::DeprecatedWarning { - old_command: "range".into(), - new_suggestion: "use `slice`".into(), - span: head, - url: "`help slice`".into(), - }, - ); - super::Slice::run(&super::Slice, engine_state, stack, call, input) - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_examples() { - use crate::test_examples; - - test_examples(Range {}) - } -} From 7f346dbf4c227cd67172abbeb520a6aab5e138d6 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 12 Mar 2025 21:43:12 +0100 Subject: [PATCH 13/59] Remove `fmt` after deprecation (#15040) # Description Follow up to https://github.com/nushell/nushell/pull/14875 # User-Facing Changes `fmt` will be gone for good. Use it under the new name `format number` ## Note Can be removed ahead of the `0.103.0` release as it was deprecated with `0.102.0` --- .../nu-cmd-extra/src/extra/conversions/fmt.rs | 74 ------------------- .../nu-cmd-extra/src/extra/conversions/mod.rs | 3 - crates/nu-cmd-extra/src/extra/mod.rs | 3 - .../src/extra/strings/format/mod.rs | 3 +- 4 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 crates/nu-cmd-extra/src/extra/conversions/fmt.rs delete mode 100644 crates/nu-cmd-extra/src/extra/conversions/mod.rs diff --git a/crates/nu-cmd-extra/src/extra/conversions/fmt.rs b/crates/nu-cmd-extra/src/extra/conversions/fmt.rs deleted file mode 100644 index 0626698fc6..0000000000 --- a/crates/nu-cmd-extra/src/extra/conversions/fmt.rs +++ /dev/null @@ -1,74 +0,0 @@ -use nu_engine::command_prelude::*; -use nu_protocol::{report_parse_warning, ParseWarning}; - -#[derive(Clone)] -pub struct Fmt; - -impl Command for Fmt { - fn name(&self) -> &str { - "fmt" - } - - fn description(&self) -> &str { - "Format a number." - } - - fn signature(&self) -> nu_protocol::Signature { - Signature::build("fmt") - .input_output_types(vec![(Type::Number, Type::record())]) - .category(Category::Deprecated) - } - - fn search_terms(&self) -> Vec<&str> { - vec![] - } - - fn examples(&self) -> Vec { - vec![Example { - description: "Get a record containing multiple formats for the number 42", - example: "42 | fmt", - result: Some(Value::test_record(record! { - "binary" => Value::test_string("0b101010"), - "debug" => Value::test_string("42"), - "display" => Value::test_string("42"), - "lowerexp" => Value::test_string("4.2e1"), - "lowerhex" => Value::test_string("0x2a"), - "octal" => Value::test_string("0o52"), - "upperexp" => Value::test_string("4.2E1"), - "upperhex" => Value::test_string("0x2A"), - })), - }] - } - - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - let head = call.head; - report_parse_warning( - &StateWorkingSet::new(engine_state), - &ParseWarning::DeprecatedWarning { - old_command: "fmt".into(), - new_suggestion: "use `format number`".into(), - span: head, - url: "`help format number`".into(), - }, - ); - crate::extra::strings::format::format_number(engine_state, stack, call, input) - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_examples() { - use crate::test_examples; - - test_examples(Fmt {}) - } -} diff --git a/crates/nu-cmd-extra/src/extra/conversions/mod.rs b/crates/nu-cmd-extra/src/extra/conversions/mod.rs deleted file mode 100644 index 3522bde067..0000000000 --- a/crates/nu-cmd-extra/src/extra/conversions/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod fmt; - -pub(crate) use fmt::Fmt; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index f2a457222a..74b12ee74c 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -1,5 +1,4 @@ mod bits; -mod conversions; mod filters; mod formats; mod math; @@ -29,8 +28,6 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { }; } - bind_command!(conversions::Fmt); - bind_command!( filters::UpdateCells, filters::EachWhile, diff --git a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs index 9f1ed1e997..e55c96685c 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs @@ -5,5 +5,4 @@ mod number; pub(crate) use command::FormatPattern; // TODO remove `format_bits` visibility after removal of into bits pub(crate) use bits::{format_bits, FormatBits}; -// TODO remove `format_number` visibility after removal of into bits -pub(crate) use number::{format_number, FormatNumber}; +pub(crate) use number::FormatNumber; From 9160f36ea564d79ca760c3b00f4fc63f85fc1021 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 12 Mar 2025 22:01:14 +0100 Subject: [PATCH 14/59] Remove `into bits` after deprecation (#15039) # Description Follow up to https://github.com/nushell/nushell/pull/14634 # User-Facing Changes `into bits` will be gone for good. Use it under the new name `format bits` ## Note Can be removed ahead of the `0.103.0` release as it was deprecated with `0.102.0` --- crates/nu-cmd-extra/src/extra/bits/into.rs | 120 ------------------ crates/nu-cmd-extra/src/extra/bits/mod.rs | 2 - crates/nu-cmd-extra/src/extra/mod.rs | 5 +- .../src/extra/strings/format/bits.rs | 3 +- .../src/extra/strings/format/mod.rs | 3 +- 5 files changed, 3 insertions(+), 130 deletions(-) delete mode 100644 crates/nu-cmd-extra/src/extra/bits/into.rs diff --git a/crates/nu-cmd-extra/src/extra/bits/into.rs b/crates/nu-cmd-extra/src/extra/bits/into.rs deleted file mode 100644 index d3979f0e47..0000000000 --- a/crates/nu-cmd-extra/src/extra/bits/into.rs +++ /dev/null @@ -1,120 +0,0 @@ -use nu_engine::command_prelude::*; - -use nu_protocol::{report_parse_warning, ParseWarning}; - -#[derive(Clone)] -pub struct BitsInto; - -impl Command for BitsInto { - fn name(&self) -> &str { - "into bits" - } - - fn signature(&self) -> Signature { - Signature::build("into bits") - .input_output_types(vec![ - (Type::Binary, Type::String), - (Type::Int, Type::String), - (Type::Filesize, Type::String), - (Type::Duration, Type::String), - (Type::String, Type::String), - (Type::Bool, Type::String), - (Type::table(), Type::table()), - (Type::record(), Type::record()), - ]) - .allow_variants_without_examples(true) // TODO: supply exhaustive examples - .rest( - "rest", - SyntaxShape::CellPath, - "For a data structure input, convert data at the given cell paths.", - ) - .category(Category::Deprecated) - } - - fn description(&self) -> &str { - "Convert value to a binary string." - } - - fn search_terms(&self) -> Vec<&str> { - vec![] - } - - fn run( - &self, - engine_state: &EngineState, - stack: &mut Stack, - call: &Call, - input: PipelineData, - ) -> Result { - let head = call.head; - report_parse_warning( - &StateWorkingSet::new(engine_state), - &ParseWarning::DeprecatedWarning { - old_command: "into bits".into(), - new_suggestion: "use `format bits`".into(), - span: head, - url: "`help format bits`".into(), - }, - ); - crate::extra::strings::format::format_bits(engine_state, stack, call, input) - } - - fn examples(&self) -> Vec { - vec![ - Example { - description: "convert a binary value into a string, padded to 8 places with 0s", - example: "0x[1] | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert an int into a string, padded to 8 places with 0s", - example: "1 | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a filesize value into a string, padded to 8 places with 0s", - example: "1b | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a duration value into a string, padded to 8 places with 0s", - example: "1ns | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a boolean value into a string, padded to 8 places with 0s", - example: "true | into bits", - result: Some(Value::string("00000001", - Span::test_data(), - )), - }, - Example { - description: "convert a string into a raw binary string, padded with 0s to 8 places", - example: "'nushell.sh' | into bits", - result: Some(Value::string("01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000", - Span::test_data(), - )), - }, - ] - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_examples() { - use crate::test_examples; - - test_examples(BitsInto {}) - } -} diff --git a/crates/nu-cmd-extra/src/extra/bits/mod.rs b/crates/nu-cmd-extra/src/extra/bits/mod.rs index 145d66d777..437313960e 100644 --- a/crates/nu-cmd-extra/src/extra/bits/mod.rs +++ b/crates/nu-cmd-extra/src/extra/bits/mod.rs @@ -1,6 +1,5 @@ mod and; mod bits_; -mod into; mod not; mod or; mod rotate_left; @@ -11,7 +10,6 @@ mod xor; pub use and::BitsAnd; pub use bits_::Bits; -pub use into::BitsInto; pub use not::BitsNot; pub use or::BitsOr; pub use rotate_left::BitsRol; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index 74b12ee74c..4dfcbdcfef 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -5,9 +5,7 @@ mod math; mod platform; mod strings; -pub use bits::{ - Bits, BitsAnd, BitsInto, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor, -}; +pub use bits::{Bits, BitsAnd, BitsNot, BitsOr, BitsRol, BitsRor, BitsShl, BitsShr, BitsXor}; pub use formats::ToHtml; pub use math::{MathArcCos, MathArcCosH, MathArcSin, MathArcSinH, MathArcTan, MathArcTanH}; pub use math::{MathCos, MathCosH, MathSin, MathSinH, MathTan, MathTanH}; @@ -60,7 +58,6 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { bind_command! { Bits, BitsAnd, - BitsInto, BitsNot, BitsOr, BitsRol, diff --git a/crates/nu-cmd-extra/src/extra/strings/format/bits.rs b/crates/nu-cmd-extra/src/extra/strings/format/bits.rs index 1010477139..04390197cb 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/bits.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/bits.rs @@ -111,8 +111,7 @@ impl Command for FormatBits { } } -// TODO: crate public only during deprecation -pub(crate) fn format_bits( +fn format_bits( engine_state: &EngineState, stack: &mut Stack, call: &Call, diff --git a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs index e55c96685c..f032474edf 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/mod.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/mod.rs @@ -2,7 +2,6 @@ mod bits; mod command; mod number; +pub(crate) use bits::FormatBits; pub(crate) use command::FormatPattern; -// TODO remove `format_bits` visibility after removal of into bits -pub(crate) use bits::{format_bits, FormatBits}; pub(crate) use number::FormatNumber; From 0f6996b70d9dd1dc99b45c9996e779e939c8eee0 Mon Sep 17 00:00:00 2001 From: Jack Wright <56345+ayax79@users.noreply.github.com> Date: Wed, 12 Mar 2025 14:11:00 -0700 Subject: [PATCH 15/59] Support for reading Categorical and Enum types (#15292) # fixes https://github.com/nushell/nushell/issues/15281 # Description Provides the ability read dataframes with Categorical and Enum data The ability to write Categorical and Enum data will provided in a future PR --- .../values/nu_dataframe/conversion.rs | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs index ad488b02d4..82051f7b1b 100644 --- a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs +++ b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs @@ -18,6 +18,7 @@ use polars::prelude::{ }; use nu_protocol::{Record, ShellError, Span, Value}; +use polars_arrow::array::Utf8ViewArray; use polars_arrow::Either; use crate::dataframe::values::NuSchema; @@ -1196,6 +1197,14 @@ fn series_to_values( })?; series_to_values(&casted, maybe_from_row, maybe_size, span) } + DataType::Categorical(maybe_rev_mapping, _categorical_ordering) + | DataType::Enum(maybe_rev_mapping, _categorical_ordering) => { + if let Some(rev_mapping) = maybe_rev_mapping { + Ok(utf8_view_array_to_value(rev_mapping.get_categories())) + } else { + Ok(vec![]) + } + } e => Err(ShellError::GenericError { error: "Error creating Dataframe".into(), msg: "".to_string(), @@ -1266,10 +1275,44 @@ fn any_value_to_value(any_value: &AnyValue, span: Span) -> Result Ok(Value::string(s.to_string(), span)), AnyValue::Binary(bytes) => Ok(Value::binary(*bytes, span)), AnyValue::BinaryOwned(bytes) => Ok(Value::binary(bytes.to_owned(), span)), + AnyValue::Categorical(_, rev_mapping, utf8_array_pointer) + | AnyValue::Enum(_, rev_mapping, utf8_array_pointer) => { + let value: Vec = if utf8_array_pointer.is_null() { + utf8_view_array_to_value(rev_mapping.get_categories()) + } else { + // This is no good way around having an unsafe block here + // as polars is using a raw pointer to the utf8 array + unsafe { + utf8_array_pointer + .get() + .as_ref() + .map(utf8_view_array_to_value) + .unwrap_or_else(Vec::new) + } + }; + Ok(Value::list(value, span)) + } + AnyValue::CategoricalOwned(_, rev_mapping, utf8_array_pointer) + | AnyValue::EnumOwned(_, rev_mapping, utf8_array_pointer) => { + let value: Vec = if utf8_array_pointer.is_null() { + utf8_view_array_to_value(rev_mapping.get_categories()) + } else { + // This is no good way around having an unsafe block here + // as polars is using a raw pointer to the utf8 array + unsafe { + utf8_array_pointer + .get() + .as_ref() + .map(utf8_view_array_to_value) + .unwrap_or_else(Vec::new) + } + }; + Ok(Value::list(value, span)) + } e => Err(ShellError::GenericError { error: "Error creating Value".into(), msg: "".to_string(), - span: None, + span: Some(span), help: Some(format!("Value not supported in nushell: {e}")), inner: Vec::new(), }), @@ -1355,6 +1398,16 @@ where } } +fn utf8_view_array_to_value(array: &Utf8ViewArray) -> Vec { + array + .iter() + .map(|x| match x { + Some(s) => Value::string(s.to_string(), Span::unknown()), + None => Value::nothing(Span::unknown()), + }) + .collect::>() +} + #[cfg(test)] mod tests { use indexmap::indexmap; From 029f3843d380f6b7dea7fd882889f9086112c705 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Thu, 13 Mar 2025 14:50:50 -0400 Subject: [PATCH 16/59] Add `default --empty` to handle empty values (#15223) # Description Adds a new `--empty/-e` flag to the `default` command. # User-Facing Changes Before: ```nushell $env.FOO = "" $env.FOO = $env.FOO? | default bar $env.FOO # => Empty string ``` After: ```nushell $env.FOO = "" $env.FOO = $env.FOO? | default -e bar $env.FOO # => bar ``` * Uses `val.is_empty`, which means that empty lists and records are also replaced * Empty values in tables (with a column specifier) are also replaced. # Tests + Formatting 7 tests added and 1 updated + 1 new example - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting N/A --- crates/nu-command/src/filters/default.rs | 32 ++++++++- crates/nu-command/tests/commands/default.rs | 74 ++++++++++++++++++++- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/crates/nu-command/src/filters/default.rs b/crates/nu-command/src/filters/default.rs index 6e5610f1be..c9a1506d4b 100644 --- a/crates/nu-command/src/filters/default.rs +++ b/crates/nu-command/src/filters/default.rs @@ -23,6 +23,11 @@ impl Command for Default { SyntaxShape::String, "The name of the column.", ) + .switch( + "empty", + "also replace empty items like \"\", {}, and []", + Some('e'), + ) .category(Category::Filters) } @@ -37,7 +42,8 @@ impl Command for Default { call: &Call, input: PipelineData, ) -> Result { - default(engine_state, stack, call, input) + let empty = call.has_flag(engine_state, stack, "empty")?; + default(engine_state, stack, call, input, empty) } fn examples(&self) -> Vec { @@ -80,6 +86,20 @@ impl Command for Default { }), ])), }, + Example { + description: r#"Replace the empty string in the "a" column of a list"#, + example: "[{a:1 b:2} {a:'' b:1}] | default -e 'N/A' a", + result: Some(Value::test_list(vec![ + Value::test_record(record! { + "a" => Value::test_int(1), + "b" => Value::test_int(2), + }), + Value::test_record(record! { + "a" => Value::test_string("N/A"), + "b" => Value::test_int(1), + }), + ])), + }, ] } } @@ -89,6 +109,7 @@ fn default( stack: &mut Stack, call: &Call, input: PipelineData, + default_when_empty: bool, ) -> Result { let metadata = input.metadata(); let value: Value = call.req(engine_state, stack, 0)?; @@ -104,7 +125,9 @@ fn default( } => { let record = record.to_mut(); if let Some(val) = record.get_mut(&column.item) { - if matches!(val, Value::Nothing { .. }) { + if matches!(val, Value::Nothing { .. }) + || (default_when_empty && val.is_empty()) + { *val = value.clone(); } } else { @@ -118,7 +141,10 @@ fn default( engine_state.signals(), ) .map(|x| x.set_metadata(metadata)) - } else if input.is_nothing() { + } else if input.is_nothing() + || (default_when_empty + && matches!(input, PipelineData::Value(ref value, _) if value.is_empty())) + { Ok(value.into_pipeline_data()) } else { Ok(input) diff --git a/crates/nu-command/tests/commands/default.rs b/crates/nu-command/tests/commands/default.rs index 6ecd14960a..1669aea4d1 100644 --- a/crates/nu-command/tests/commands/default.rs +++ b/crates/nu-command/tests/commands/default.rs @@ -5,10 +5,13 @@ fn adds_row_data_if_column_missing() { let sample = r#" { "amigos": [ - {"name": "Yehuda"}, + {"name": "Yehuda"}, {"name": "JT", "rusty_luck": 0}, - {"name": "Andres", "rusty_luck": 0}, - {"name":"GorbyPuff"} + {"name": "Andres", "rusty_luck": 0}, + {"name": "Michael", "rusty_luck": []}, + {"name": "Darren", "rusty_luck": {}}, + {"name": "Stefan", "rusty_luck": ""}, + {"name": "GorbyPuff"} ] } "#; @@ -44,3 +47,68 @@ fn replaces_null() { let actual = nu!(r#"null | default 1"#); assert_eq!(actual.out, "1"); } + +#[test] +fn adds_row_data_if_column_missing_or_empty() { + let sample = r#" + { + "amigos": [ + {"name": "Yehuda"}, + {"name": "JT", "rusty_luck": 0}, + {"name": "Andres", "rusty_luck": 0}, + {"name": "Michael", "rusty_luck": []}, + {"name": "Darren", "rusty_luck": {}}, + {"name": "Stefan", "rusty_luck": ""}, + {"name": "GorbyPuff"} + ] + } + "#; + + let actual = nu!(pipeline(&format!( + " + {sample} + | get amigos + | default -e 1 rusty_luck + | where rusty_luck == 1 + | length + " + ))); + + assert_eq!(actual.out, "5"); +} + +#[test] +fn replace_empty_string() { + let actual = nu!(r#"'' | default -e foo"#); + assert_eq!(actual.out, "foo"); +} + +#[test] +fn do_not_replace_empty_string() { + let actual = nu!(r#"'' | default 1"#); + assert_eq!(actual.out, ""); +} + +#[test] +fn replace_empty_list() { + let actual = nu!(r#"[] | default -e foo"#); + assert_eq!(actual.out, "foo"); +} + +#[test] +fn do_not_replace_empty_list() { + let actual = nu!(r#"[] | default 1 | length"#); + assert_eq!(actual.out, "0"); +} + +#[test] +fn replace_empty_record() { + let actual = nu!(r#"{} | default -e foo"#); + assert_eq!(actual.out, "foo"); +} + +#[test] +fn do_not_replace_empty_record() { + let actual = nu!(r#"{} | default {a:5} | columns | length"#); + assert_eq!(actual.out, "0"); +} From 3dde85138167b7d266f3c9fd6a84a2d848b8dda5 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Thu, 13 Mar 2025 20:31:52 +0100 Subject: [PATCH 17/59] Bump reedline for recent completion fix (#15310) Pulls in nushell/reedline#886 Related #13630 --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8358295a59..df9c06de8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -689,7 +689,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "regex", @@ -5844,7 +5844,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.38.0" -source = "git+https://github.com/nushell/reedline?branch=main#f12c4f16aaeff9fd62ca8b2c75606b40e32489c7" +source = "git+https://github.com/nushell/reedline?branch=main#dfdb167390bf9b550535cb8b5132e3122fd9f136" dependencies = [ "arboard", "chrono", @@ -8078,7 +8078,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] From f4b7333dc825d9337755a243d7fe135239b1d99b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:40:56 +0000 Subject: [PATCH 18/59] build(deps): bump scraper from 0.22.0 to 0.23.1 (#15294) --- Cargo.lock | 4 ++-- crates/nu_plugin_query/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df9c06de8f..b10365a529 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6334,9 +6334,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scraper" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc3d051b884f40e309de6c149734eab57aa8cc1347992710dc80bcc1c2194c15" +checksum = "527e65d9d888567588db4c12da1087598d0f6f8b346cc2c5abc91f05fc2dffe2" dependencies = [ "cssparser", "ego-tree", diff --git a/crates/nu_plugin_query/Cargo.toml b/crates/nu_plugin_query/Cargo.toml index 06c2fdcc4a..c0e09f784e 100644 --- a/crates/nu_plugin_query/Cargo.toml +++ b/crates/nu_plugin_query/Cargo.toml @@ -20,7 +20,7 @@ nu-plugin = { path = "../nu-plugin", version = "0.102.1" } nu-protocol = { path = "../nu-protocol", version = "0.102.1" } gjson = "0.8" -scraper = { default-features = false, version = "0.22" } +scraper = { default-features = false, version = "0.23" } sxd-document = "0.3" sxd-xpath = "0.4" webpage = { version = "2.0.1", features = ["serde"] } From 33001d1992807ca712d140b0513c2454e70a5755 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:41:30 +0000 Subject: [PATCH 19/59] build(deps): bump titlecase from 3.3.0 to 3.4.0 (#15295) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b10365a529..b875372064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7180,9 +7180,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "titlecase" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e20e744fbec1913fa168f3ffbef64324bbcb152c6cda8394baa79fa5ec9142" +checksum = "ef6b5cbe1316986025d8f662ff6945a0c85f2ca8ca13f04b5e0829ddb0d047f2" dependencies = [ "regex", ] diff --git a/Cargo.toml b/Cargo.toml index bb6b35246c..a237777e22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -161,7 +161,7 @@ syn = "2.0" sysinfo = "0.33" tabled = { version = "0.17.0", default-features = false } tempfile = "3.15" -titlecase = "3.0" +titlecase = "3.4" toml = "0.8" trash = "5.2" update-informer = { version = "1.2.0", default-features = false, features = ["github", "native-tls", "ureq"] } From 8f634f41403fb3123dcfdae7cba68b5049bd74c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= <96702577+LoicRiegel@users.noreply.github.com> Date: Fri, 14 Mar 2025 02:00:35 +0100 Subject: [PATCH 20/59] refactor: rename subcommand structs (#15309) Came from [this discussion](https://discord.com/channels/601130461678272522/1348791953784836147/1349699872059691038) on discord with @fdncred # Description Small refactoring where I rename commands from "SubCommand" to its proper name. Motivations: better clarity (although subjective), better searchable, consistency. The only commands I didn't touch were "split list" and "ansi gradient" because of name clashes. # User-Facing Changes None # Tests + Formatting cargo fmt and clippy OK # After Submitting nothing required --- .../nu-cli/src/commands/commandline/edit.rs | 4 +-- .../src/commands/commandline/get_cursor.rs | 4 +-- crates/nu-cli/src/commands/commandline/mod.rs | 6 ++-- .../src/commands/commandline/set_cursor.rs | 4 +-- crates/nu-cmd-extra/src/extra/math/arccos.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/arccosh.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/arcsin.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/arcsinh.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/arctan.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/arctanh.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/cos.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/cosh.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/exp.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/ln.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/mod.rs | 28 ++++++++--------- crates/nu-cmd-extra/src/extra/math/sin.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/sinh.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/tan.rs | 6 ++-- crates/nu-cmd-extra/src/extra/math/tanh.rs | 6 ++-- .../src/extra/strings/str_/case/camel_case.rs | 6 ++-- .../src/extra/strings/str_/case/kebab_case.rs | 6 ++-- .../src/extra/strings/str_/case/mod.rs | 12 ++++---- .../extra/strings/str_/case/pascal_case.rs | 6 ++-- .../strings/str_/case/screaming_snake_case.rs | 6 ++-- .../src/extra/strings/str_/case/snake_case.rs | 6 ++-- .../src/extra/strings/str_/case/title_case.rs | 6 ++-- .../nu-command/src/conversions/into/binary.rs | 6 ++-- .../nu-command/src/conversions/into/bool.rs | 6 ++-- .../src/conversions/into/datetime.rs | 8 ++--- .../src/conversions/into/duration.rs | 6 ++-- .../src/conversions/into/filesize.rs | 6 ++-- .../nu-command/src/conversions/into/float.rs | 6 ++-- .../nu-command/src/conversions/into/glob.rs | 6 ++-- crates/nu-command/src/conversions/into/int.rs | 6 ++-- crates/nu-command/src/conversions/into/mod.rs | 20 ++++++------- .../nu-command/src/conversions/into/record.rs | 6 ++-- .../nu-command/src/conversions/into/string.rs | 6 ++-- crates/nu-command/src/conversions/mod.rs | 2 +- .../src/conversions/split_cell_path.rs | 6 ++-- crates/nu-command/src/date/humanize.rs | 6 ++-- crates/nu-command/src/date/list_timezone.rs | 4 +-- crates/nu-command/src/date/mod.rs | 8 ++--- crates/nu-command/src/date/now.rs | 4 +-- crates/nu-command/src/date/to_timezone.rs | 6 ++-- crates/nu-command/src/math/abs.rs | 6 ++-- crates/nu-command/src/math/avg.rs | 6 ++-- crates/nu-command/src/math/ceil.rs | 6 ++-- crates/nu-command/src/math/floor.rs | 6 ++-- crates/nu-command/src/math/log.rs | 6 ++-- crates/nu-command/src/math/max.rs | 6 ++-- crates/nu-command/src/math/median.rs | 6 ++-- crates/nu-command/src/math/min.rs | 6 ++-- crates/nu-command/src/math/mod.rs | 30 +++++++++---------- crates/nu-command/src/math/mode.rs | 6 ++-- crates/nu-command/src/math/product.rs | 6 ++-- crates/nu-command/src/math/round.rs | 6 ++-- crates/nu-command/src/math/sqrt.rs | 6 ++-- crates/nu-command/src/math/stddev.rs | 6 ++-- crates/nu-command/src/math/sum.rs | 6 ++-- crates/nu-command/src/math/variance.rs | 6 ++-- crates/nu-command/src/network/http/delete.rs | 6 ++-- crates/nu-command/src/network/http/get.rs | 6 ++-- crates/nu-command/src/network/http/head.rs | 6 ++-- crates/nu-command/src/network/http/mod.rs | 14 ++++----- crates/nu-command/src/network/http/options.rs | 6 ++-- crates/nu-command/src/network/http/patch.rs | 6 ++-- crates/nu-command/src/network/http/post.rs | 6 ++-- crates/nu-command/src/network/http/put.rs | 6 ++-- crates/nu-command/src/network/mod.rs | 2 +- crates/nu-command/src/network/port.rs | 4 +-- .../nu-command/src/network/url/build_query.rs | 6 ++-- crates/nu-command/src/network/url/decode.rs | 6 ++-- crates/nu-command/src/network/url/encode.rs | 6 ++-- crates/nu-command/src/network/url/join.rs | 6 ++-- crates/nu-command/src/network/url/mod.rs | 12 ++++---- crates/nu-command/src/network/url/parse.rs | 6 ++-- .../nu-command/src/network/url/split_query.rs | 6 ++-- crates/nu-command/src/path/basename.rs | 6 ++-- crates/nu-command/src/path/dirname.rs | 6 ++-- crates/nu-command/src/path/exists.rs | 6 ++-- crates/nu-command/src/path/expand.rs | 6 ++-- crates/nu-command/src/path/join.rs | 6 ++-- crates/nu-command/src/path/mod.rs | 22 +++++++------- crates/nu-command/src/path/parse.rs | 6 ++-- crates/nu-command/src/path/path_.rs | 4 +-- crates/nu-command/src/path/relative_to.rs | 6 ++-- crates/nu-command/src/path/self_.rs | 6 ++-- crates/nu-command/src/path/split.rs | 6 ++-- crates/nu-command/src/path/type.rs | 6 ++-- crates/nu-command/src/platform/ansi/ansi_.rs | 8 ++--- crates/nu-command/src/platform/ansi/link.rs | 8 ++--- crates/nu-command/src/platform/ansi/mod.rs | 6 ++-- crates/nu-command/src/platform/ansi/strip.rs | 8 ++--- crates/nu-command/src/random/binary.rs | 6 ++-- crates/nu-command/src/random/bool.rs | 6 ++-- crates/nu-command/src/random/chars.rs | 6 ++-- crates/nu-command/src/random/dice.rs | 6 ++-- crates/nu-command/src/random/float.rs | 6 ++-- crates/nu-command/src/random/int.rs | 6 ++-- crates/nu-command/src/random/mod.rs | 16 +++++----- crates/nu-command/src/random/random_.rs | 4 +-- crates/nu-command/src/random/uuid.rs | 6 ++-- crates/nu-command/src/removed/format.rs | 4 +-- crates/nu-command/src/removed/mod.rs | 2 +- crates/nu-command/src/strings/split/chars.rs | 6 ++-- crates/nu-command/src/strings/split/column.rs | 6 ++-- .../nu-command/src/strings/split/command.rs | 4 +-- crates/nu-command/src/strings/split/mod.rs | 10 +++---- crates/nu-command/src/strings/split/row.rs | 6 ++-- crates/nu-command/src/strings/split/words.rs | 6 ++-- .../src/strings/str_/case/capitalize.rs | 6 ++-- .../src/strings/str_/case/downcase.rs | 6 ++-- .../nu-command/src/strings/str_/case/mod.rs | 6 ++-- .../src/strings/str_/case/upcase.rs | 8 ++--- .../nu-command/src/strings/str_/contains.rs | 6 ++-- .../nu-command/src/strings/str_/distance.rs | 6 ++-- .../nu-command/src/strings/str_/ends_with.rs | 6 ++-- crates/nu-command/src/strings/str_/expand.rs | 6 ++-- .../nu-command/src/strings/str_/index_of.rs | 8 ++--- crates/nu-command/src/strings/str_/length.rs | 6 ++-- crates/nu-command/src/strings/str_/mod.rs | 24 +++++++-------- crates/nu-command/src/strings/str_/replace.rs | 8 ++--- crates/nu-command/src/strings/str_/reverse.rs | 6 ++-- .../src/strings/str_/starts_with.rs | 6 ++-- crates/nu-command/src/strings/str_/stats.rs | 6 ++-- .../nu-command/src/strings/str_/substring.rs | 8 ++--- .../nu-command/src/strings/str_/trim/mod.rs | 2 +- .../nu-command/src/strings/str_/trim/trim_.rs | 6 ++-- 128 files changed, 439 insertions(+), 439 deletions(-) diff --git a/crates/nu-cli/src/commands/commandline/edit.rs b/crates/nu-cli/src/commands/commandline/edit.rs index 9afd52d946..7b51ba0002 100644 --- a/crates/nu-cli/src/commands/commandline/edit.rs +++ b/crates/nu-cli/src/commands/commandline/edit.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct CommandlineEdit; -impl Command for SubCommand { +impl Command for CommandlineEdit { fn name(&self) -> &str { "commandline edit" } diff --git a/crates/nu-cli/src/commands/commandline/get_cursor.rs b/crates/nu-cli/src/commands/commandline/get_cursor.rs index 7c49309702..61050f6ae3 100644 --- a/crates/nu-cli/src/commands/commandline/get_cursor.rs +++ b/crates/nu-cli/src/commands/commandline/get_cursor.rs @@ -2,9 +2,9 @@ use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] -pub struct SubCommand; +pub struct CommandlineGetCursor; -impl Command for SubCommand { +impl Command for CommandlineGetCursor { fn name(&self) -> &str { "commandline get-cursor" } diff --git a/crates/nu-cli/src/commands/commandline/mod.rs b/crates/nu-cli/src/commands/commandline/mod.rs index d3991c0fa5..bb4c9b05e3 100644 --- a/crates/nu-cli/src/commands/commandline/mod.rs +++ b/crates/nu-cli/src/commands/commandline/mod.rs @@ -4,6 +4,6 @@ mod get_cursor; mod set_cursor; pub use commandline_::Commandline; -pub use edit::SubCommand as CommandlineEdit; -pub use get_cursor::SubCommand as CommandlineGetCursor; -pub use set_cursor::SubCommand as CommandlineSetCursor; +pub use edit::CommandlineEdit; +pub use get_cursor::CommandlineGetCursor; +pub use set_cursor::CommandlineSetCursor; diff --git a/crates/nu-cli/src/commands/commandline/set_cursor.rs b/crates/nu-cli/src/commands/commandline/set_cursor.rs index bf54674b44..012bd8c7a4 100644 --- a/crates/nu-cli/src/commands/commandline/set_cursor.rs +++ b/crates/nu-cli/src/commands/commandline/set_cursor.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] -pub struct SubCommand; +pub struct CommandlineSetCursor; -impl Command for SubCommand { +impl Command for CommandlineSetCursor { fn name(&self) -> &str { "commandline set-cursor" } diff --git a/crates/nu-cmd-extra/src/extra/math/arccos.rs b/crates/nu-cmd-extra/src/extra/math/arccos.rs index 229e7e4520..bf7dd18555 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccos.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccos.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcCos; -impl Command for SubCommand { +impl Command for MathArcCos { fn name(&self) -> &str { "math arccos" } @@ -114,6 +114,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcCos {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/arccosh.rs b/crates/nu-cmd-extra/src/extra/math/arccosh.rs index c15c72dc36..5f8a5f691f 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccosh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcCosH; -impl Command for SubCommand { +impl Command for MathArcCosH { fn name(&self) -> &str { "math arccosh" } @@ -100,6 +100,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcCosH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/arcsin.rs b/crates/nu-cmd-extra/src/extra/math/arcsin.rs index b1f4438e2b..817438d2ff 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsin.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsin.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcSin; -impl Command for SubCommand { +impl Command for MathArcSin { fn name(&self) -> &str { "math arcsin" } @@ -115,6 +115,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcSin {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs index a2fce1f057..6faa2dda67 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcSinH; -impl Command for SubCommand { +impl Command for MathArcSinH { fn name(&self) -> &str { "math arcsinh" } @@ -88,6 +88,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcSinH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/arctan.rs b/crates/nu-cmd-extra/src/extra/math/arctan.rs index f3bcc74150..17de98b1f9 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctan.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctan.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcTan; -impl Command for SubCommand { +impl Command for MathArcTan { fn name(&self) -> &str { "math arctan" } @@ -102,6 +102,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcTan {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/arctanh.rs b/crates/nu-cmd-extra/src/extra/math/arctanh.rs index bd01e7f101..97fb7274c9 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctanh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathArcTanH; -impl Command for SubCommand { +impl Command for MathArcTanH { fn name(&self) -> &str { "math arctanh" } @@ -101,6 +101,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathArcTanH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/cos.rs b/crates/nu-cmd-extra/src/extra/math/cos.rs index 5ec0777edf..c5d776301f 100644 --- a/crates/nu-cmd-extra/src/extra/math/cos.rs +++ b/crates/nu-cmd-extra/src/extra/math/cos.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathCos; -impl Command for SubCommand { +impl Command for MathCos { fn name(&self) -> &str { "math cos" } @@ -108,6 +108,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathCos {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/cosh.rs b/crates/nu-cmd-extra/src/extra/math/cosh.rs index 68bdc6094a..46ec992562 100644 --- a/crates/nu-cmd-extra/src/extra/math/cosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/cosh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathCosH; -impl Command for SubCommand { +impl Command for MathCosH { fn name(&self) -> &str { "math cosh" } @@ -88,6 +88,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathCosH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/exp.rs b/crates/nu-cmd-extra/src/extra/math/exp.rs index 0b28274dae..b8954bd26c 100644 --- a/crates/nu-cmd-extra/src/extra/math/exp.rs +++ b/crates/nu-cmd-extra/src/extra/math/exp.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathExp; -impl Command for SubCommand { +impl Command for MathExp { fn name(&self) -> &str { "math exp" } @@ -93,6 +93,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathExp {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/ln.rs b/crates/nu-cmd-extra/src/extra/math/ln.rs index 147f536028..60890faeed 100644 --- a/crates/nu-cmd-extra/src/extra/math/ln.rs +++ b/crates/nu-cmd-extra/src/extra/math/ln.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathLn; -impl Command for SubCommand { +impl Command for MathLn { fn name(&self) -> &str { "math ln" } @@ -100,6 +100,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathLn {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/mod.rs b/crates/nu-cmd-extra/src/extra/math/mod.rs index 6da13a181c..239a57d8c1 100644 --- a/crates/nu-cmd-extra/src/extra/math/mod.rs +++ b/crates/nu-cmd-extra/src/extra/math/mod.rs @@ -15,19 +15,19 @@ mod arcsinh; mod arctan; mod arctanh; -pub use cos::SubCommand as MathCos; -pub use cosh::SubCommand as MathCosH; -pub use sin::SubCommand as MathSin; -pub use sinh::SubCommand as MathSinH; -pub use tan::SubCommand as MathTan; -pub use tanh::SubCommand as MathTanH; +pub use cos::MathCos; +pub use cosh::MathCosH; +pub use sin::MathSin; +pub use sinh::MathSinH; +pub use tan::MathTan; +pub use tanh::MathTanH; -pub use exp::SubCommand as MathExp; -pub use ln::SubCommand as MathLn; +pub use exp::MathExp; +pub use ln::MathLn; -pub use arccos::SubCommand as MathArcCos; -pub use arccosh::SubCommand as MathArcCosH; -pub use arcsin::SubCommand as MathArcSin; -pub use arcsinh::SubCommand as MathArcSinH; -pub use arctan::SubCommand as MathArcTan; -pub use arctanh::SubCommand as MathArcTanH; +pub use arccos::MathArcCos; +pub use arccosh::MathArcCosH; +pub use arcsin::MathArcSin; +pub use arcsinh::MathArcSinH; +pub use arctan::MathArcTan; +pub use arctanh::MathArcTanH; diff --git a/crates/nu-cmd-extra/src/extra/math/sin.rs b/crates/nu-cmd-extra/src/extra/math/sin.rs index fcaa693b8d..e22dea8ba9 100644 --- a/crates/nu-cmd-extra/src/extra/math/sin.rs +++ b/crates/nu-cmd-extra/src/extra/math/sin.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathSin; -impl Command for SubCommand { +impl Command for MathSin { fn name(&self) -> &str { "math sin" } @@ -108,6 +108,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathSin {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/sinh.rs b/crates/nu-cmd-extra/src/extra/math/sinh.rs index 2e852e42f1..3ac7d8fd98 100644 --- a/crates/nu-cmd-extra/src/extra/math/sinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/sinh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathSinH; -impl Command for SubCommand { +impl Command for MathSinH { fn name(&self) -> &str { "math sinh" } @@ -87,6 +87,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathSinH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/tan.rs b/crates/nu-cmd-extra/src/extra/math/tan.rs index 025b9817c5..81a81aaadf 100644 --- a/crates/nu-cmd-extra/src/extra/math/tan.rs +++ b/crates/nu-cmd-extra/src/extra/math/tan.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathTan; -impl Command for SubCommand { +impl Command for MathTan { fn name(&self) -> &str { "math tan" } @@ -106,6 +106,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathTan {}) } } diff --git a/crates/nu-cmd-extra/src/extra/math/tanh.rs b/crates/nu-cmd-extra/src/extra/math/tanh.rs index 9ac10444d9..1a097370b1 100644 --- a/crates/nu-cmd-extra/src/extra/math/tanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/tanh.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathTanH; -impl Command for SubCommand { +impl Command for MathTanH { fn name(&self) -> &str { "math tanh" } @@ -86,6 +86,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathTanH {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs index 279e3a7bb5..a2809bde54 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/camel_case.rs @@ -3,9 +3,9 @@ use heck::ToLowerCamelCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrCamelCase; -impl Command for SubCommand { +impl Command for StrCamelCase { fn name(&self) -> &str { "str camel-case" } @@ -91,6 +91,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrCamelCase {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs index 89a3429d7a..61ba7d8b68 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/kebab_case.rs @@ -3,9 +3,9 @@ use heck::ToKebabCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrKebabCase; -impl Command for SubCommand { +impl Command for StrKebabCase { fn name(&self) -> &str { "str kebab-case" } @@ -90,6 +90,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrKebabCase {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs index bfa54921e2..93a681e95f 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/mod.rs @@ -6,13 +6,13 @@ mod snake_case; mod str_; mod title_case; -pub use camel_case::SubCommand as StrCamelCase; -pub use kebab_case::SubCommand as StrKebabCase; -pub use pascal_case::SubCommand as StrPascalCase; -pub use screaming_snake_case::SubCommand as StrScreamingSnakeCase; -pub use snake_case::SubCommand as StrSnakeCase; +pub use camel_case::StrCamelCase; +pub use kebab_case::StrKebabCase; +pub use pascal_case::StrPascalCase; +pub use screaming_snake_case::StrScreamingSnakeCase; +pub use snake_case::StrSnakeCase; pub use str_::Str; -pub use title_case::SubCommand as StrTitleCase; +pub use title_case::StrTitleCase; use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; use nu_engine::command_prelude::*; diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs index 9d081fa314..ff15ceeebd 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/pascal_case.rs @@ -3,9 +3,9 @@ use heck::ToUpperCamelCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrPascalCase; -impl Command for SubCommand { +impl Command for StrPascalCase { fn name(&self) -> &str { "str pascal-case" } @@ -91,6 +91,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrPascalCase {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs index aa8d55fd48..ef552544d2 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/screaming_snake_case.rs @@ -3,9 +3,9 @@ use heck::ToShoutySnakeCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrScreamingSnakeCase; -impl Command for SubCommand { +impl Command for StrScreamingSnakeCase { fn name(&self) -> &str { "str screaming-snake-case" } @@ -91,6 +91,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrScreamingSnakeCase {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs index f2d5fb61c7..a3913ebb30 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/snake_case.rs @@ -3,9 +3,9 @@ use heck::ToSnakeCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrSnakeCase; -impl Command for SubCommand { +impl Command for StrSnakeCase { fn name(&self) -> &str { "str snake-case" } @@ -91,6 +91,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrSnakeCase {}) } } diff --git a/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs b/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs index 827a3dd594..7f83059538 100644 --- a/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs +++ b/crates/nu-cmd-extra/src/extra/strings/str_/case/title_case.rs @@ -3,9 +3,9 @@ use heck::ToTitleCase; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrTitleCase; -impl Command for SubCommand { +impl Command for StrTitleCase { fn name(&self) -> &str { "str title-case" } @@ -86,6 +86,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrTitleCase {}) } } diff --git a/crates/nu-command/src/conversions/into/binary.rs b/crates/nu-command/src/conversions/into/binary.rs index 3993f65d19..3a9c6077ab 100644 --- a/crates/nu-command/src/conversions/into/binary.rs +++ b/crates/nu-command/src/conversions/into/binary.rs @@ -13,9 +13,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct IntoBinary; -impl Command for SubCommand { +impl Command for IntoBinary { fn name(&self) -> &str { "into binary" } @@ -204,7 +204,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoBinary {}) } #[rstest] diff --git a/crates/nu-command/src/conversions/into/bool.rs b/crates/nu-command/src/conversions/into/bool.rs index d093e69ad8..b2de275497 100644 --- a/crates/nu-command/src/conversions/into/bool.rs +++ b/crates/nu-command/src/conversions/into/bool.rs @@ -2,9 +2,9 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct IntoBool; -impl Command for SubCommand { +impl Command for IntoBool { fn name(&self) -> &str { "into bool" } @@ -202,7 +202,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoBool {}) } #[test] diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 54930bbc45..076571f085 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -49,9 +49,9 @@ impl Zone { } #[derive(Clone)] -pub struct SubCommand; +pub struct IntoDatetime; -impl Command for SubCommand { +impl Command for IntoDatetime { fn name(&self) -> &str { "into datetime" } @@ -495,14 +495,14 @@ fn list_human_readable_examples(span: Span) -> Value { #[cfg(test)] mod tests { use super::*; - use super::{action, DatetimeFormat, SubCommand, Zone}; + use super::{action, DatetimeFormat, IntoDatetime, Zone}; use nu_protocol::Type::Error; #[test] fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoDatetime {}) } #[test] diff --git a/crates/nu-command/src/conversions/into/duration.rs b/crates/nu-command/src/conversions/into/duration.rs index 3d11b83afb..129188f839 100644 --- a/crates/nu-command/src/conversions/into/duration.rs +++ b/crates/nu-command/src/conversions/into/duration.rs @@ -4,9 +4,9 @@ use nu_protocol::{ast::Expr, Unit}; const NS_PER_SEC: i64 = 1_000_000_000; #[derive(Clone)] -pub struct SubCommand; +pub struct IntoDuration; -impl Command for SubCommand { +impl Command for IntoDuration { fn name(&self) -> &str { "into duration" } @@ -277,7 +277,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoDuration {}) } const NS_PER_SEC: i64 = 1_000_000_000; diff --git a/crates/nu-command/src/conversions/into/filesize.rs b/crates/nu-command/src/conversions/into/filesize.rs index 98b63597e7..90f4c1a208 100644 --- a/crates/nu-command/src/conversions/into/filesize.rs +++ b/crates/nu-command/src/conversions/into/filesize.rs @@ -4,9 +4,9 @@ use nu_engine::command_prelude::*; use nu_utils::get_system_locale; #[derive(Clone)] -pub struct SubCommand; +pub struct IntoFilesize; -impl Command for SubCommand { +impl Command for IntoFilesize { fn name(&self) -> &str { "into filesize" } @@ -197,6 +197,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoFilesize {}) } } diff --git a/crates/nu-command/src/conversions/into/float.rs b/crates/nu-command/src/conversions/into/float.rs index 23ada8c5a9..24f79d3204 100644 --- a/crates/nu-command/src/conversions/into/float.rs +++ b/crates/nu-command/src/conversions/into/float.rs @@ -2,9 +2,9 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct IntoFloat; -impl Command for SubCommand { +impl Command for IntoFloat { fn name(&self) -> &str { "into float" } @@ -134,7 +134,7 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoFloat {}) } #[test] diff --git a/crates/nu-command/src/conversions/into/glob.rs b/crates/nu-command/src/conversions/into/glob.rs index e935476900..040e073089 100644 --- a/crates/nu-command/src/conversions/into/glob.rs +++ b/crates/nu-command/src/conversions/into/glob.rs @@ -12,9 +12,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct IntoGlob; -impl Command for SubCommand { +impl Command for IntoGlob { fn name(&self) -> &str { "into glob" } @@ -121,6 +121,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoGlob {}) } } diff --git a/crates/nu-command/src/conversions/into/int.rs b/crates/nu-command/src/conversions/into/int.rs index 67cba23090..4c3a53dbce 100644 --- a/crates/nu-command/src/conversions/into/int.rs +++ b/crates/nu-command/src/conversions/into/int.rs @@ -18,9 +18,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct IntoInt; -impl Command for SubCommand { +impl Command for IntoInt { fn name(&self) -> &str { "into int" } @@ -521,7 +521,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoInt {}) } #[test] diff --git a/crates/nu-command/src/conversions/into/mod.rs b/crates/nu-command/src/conversions/into/mod.rs index 50258c338a..9f975efc78 100644 --- a/crates/nu-command/src/conversions/into/mod.rs +++ b/crates/nu-command/src/conversions/into/mod.rs @@ -12,16 +12,16 @@ mod record; mod string; mod value; -pub use self::bool::SubCommand as IntoBool; -pub use self::filesize::SubCommand as IntoFilesize; -pub use binary::SubCommand as IntoBinary; +pub use binary::IntoBinary; +pub use bool::IntoBool; pub use cell_path::IntoCellPath; pub use command::Into; -pub use datetime::SubCommand as IntoDatetime; -pub use duration::SubCommand as IntoDuration; -pub use float::SubCommand as IntoFloat; -pub use glob::SubCommand as IntoGlob; -pub use int::SubCommand as IntoInt; -pub use record::SubCommand as IntoRecord; -pub use string::SubCommand as IntoString; +pub use datetime::IntoDatetime; +pub use duration::IntoDuration; +pub use filesize::IntoFilesize; +pub use float::IntoFloat; +pub use glob::IntoGlob; +pub use int::IntoInt; +pub use record::IntoRecord; +pub use string::IntoString; pub use value::IntoValue; diff --git a/crates/nu-command/src/conversions/into/record.rs b/crates/nu-command/src/conversions/into/record.rs index fea5fe1e4e..bba7dc9d7c 100644 --- a/crates/nu-command/src/conversions/into/record.rs +++ b/crates/nu-command/src/conversions/into/record.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use nu_protocol::format_duration_as_timeperiod; #[derive(Clone)] -pub struct SubCommand; +pub struct IntoRecord; -impl Command for SubCommand { +impl Command for IntoRecord { fn name(&self) -> &str { "into record" } @@ -243,6 +243,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoRecord {}) } } diff --git a/crates/nu-command/src/conversions/into/string.rs b/crates/nu-command/src/conversions/into/string.rs index 42eabc8935..cc48754361 100644 --- a/crates/nu-command/src/conversions/into/string.rs +++ b/crates/nu-command/src/conversions/into/string.rs @@ -19,9 +19,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct IntoString; -impl Command for SubCommand { +impl Command for IntoString { fn name(&self) -> &str { "into string" } @@ -316,6 +316,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(IntoString {}) } } diff --git a/crates/nu-command/src/conversions/mod.rs b/crates/nu-command/src/conversions/mod.rs index b67c77936f..52f589219d 100644 --- a/crates/nu-command/src/conversions/mod.rs +++ b/crates/nu-command/src/conversions/mod.rs @@ -4,4 +4,4 @@ mod split_cell_path; pub use fill::Fill; pub use into::*; -pub use split_cell_path::SubCommand as SplitCellPath; +pub use split_cell_path::SplitCellPath; diff --git a/crates/nu-command/src/conversions/split_cell_path.rs b/crates/nu-command/src/conversions/split_cell_path.rs index 27c457b356..4ff5bff67c 100644 --- a/crates/nu-command/src/conversions/split_cell_path.rs +++ b/crates/nu-command/src/conversions/split_cell_path.rs @@ -2,9 +2,9 @@ use nu_engine::command_prelude::*; use nu_protocol::{ast::PathMember, IntoValue}; #[derive(Clone)] -pub struct SubCommand; +pub struct SplitCellPath; -impl Command for SubCommand { +impl Command for SplitCellPath { fn name(&self) -> &str { "split cell-path" } @@ -150,6 +150,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(SplitCellPath {}) } } diff --git a/crates/nu-command/src/date/humanize.rs b/crates/nu-command/src/date/humanize.rs index 3f3300a94d..5670d1faed 100644 --- a/crates/nu-command/src/date/humanize.rs +++ b/crates/nu-command/src/date/humanize.rs @@ -4,9 +4,9 @@ use chrono_humanize::HumanTime; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct DateHumanize; -impl Command for SubCommand { +impl Command for DateHumanize { fn name(&self) -> &str { "date humanize" } @@ -101,6 +101,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(DateHumanize {}) } } diff --git a/crates/nu-command/src/date/list_timezone.rs b/crates/nu-command/src/date/list_timezone.rs index 6b7c448af2..3b7bb41eae 100644 --- a/crates/nu-command/src/date/list_timezone.rs +++ b/crates/nu-command/src/date/list_timezone.rs @@ -2,9 +2,9 @@ use chrono_tz::TZ_VARIANTS; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct DateListTimezones; -impl Command for SubCommand { +impl Command for DateListTimezones { fn name(&self) -> &str { "date list-timezone" } diff --git a/crates/nu-command/src/date/mod.rs b/crates/nu-command/src/date/mod.rs index fc0aaf95c0..385420c911 100644 --- a/crates/nu-command/src/date/mod.rs +++ b/crates/nu-command/src/date/mod.rs @@ -7,8 +7,8 @@ mod to_timezone; mod utils; pub use date_::Date; -pub use humanize::SubCommand as DateHumanize; -pub use list_timezone::SubCommand as DateListTimezones; -pub use now::SubCommand as DateNow; -pub use to_timezone::SubCommand as DateToTimezone; +pub use humanize::DateHumanize; +pub use list_timezone::DateListTimezones; +pub use now::DateNow; +pub use to_timezone::DateToTimezone; pub(crate) use utils::{generate_strftime_list, parse_date_from_string}; diff --git a/crates/nu-command/src/date/now.rs b/crates/nu-command/src/date/now.rs index 5492db9863..b3fca4ade2 100644 --- a/crates/nu-command/src/date/now.rs +++ b/crates/nu-command/src/date/now.rs @@ -2,9 +2,9 @@ use chrono::Local; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct DateNow; -impl Command for SubCommand { +impl Command for DateNow { fn name(&self) -> &str { "date now" } diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index e5e354f9cc..891d80805c 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -4,9 +4,9 @@ use chrono::{DateTime, FixedOffset, Local, LocalResult, TimeZone}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct DateToTimezone; -impl Command for SubCommand { +impl Command for DateToTimezone { fn name(&self) -> &str { "date to-timezone" } @@ -147,6 +147,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(DateToTimezone {}) } } diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index 95cf251abb..4fae0633c8 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathAbs; -impl Command for SubCommand { +impl Command for MathAbs { fn name(&self) -> &str { "math abs" } @@ -105,6 +105,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathAbs {}) } } diff --git a/crates/nu-command/src/math/avg.rs b/crates/nu-command/src/math/avg.rs index a7f6d3088a..68e2de0a15 100644 --- a/crates/nu-command/src/math/avg.rs +++ b/crates/nu-command/src/math/avg.rs @@ -6,9 +6,9 @@ use nu_engine::command_prelude::*; const NS_PER_SEC: i64 = 1_000_000_000; #[derive(Clone)] -pub struct SubCommand; +pub struct MathAvg; -impl Command for SubCommand { +impl Command for MathAvg { fn name(&self) -> &str { "math avg" } @@ -104,6 +104,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathAvg {}) } } diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index a971ef3975..5867f21bca 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathCeil; -impl Command for SubCommand { +impl Command for MathCeil { fn name(&self) -> &str { "math ceil" } @@ -103,6 +103,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathCeil {}) } } diff --git a/crates/nu-command/src/math/floor.rs b/crates/nu-command/src/math/floor.rs index 2dfa293b24..2bc705f926 100644 --- a/crates/nu-command/src/math/floor.rs +++ b/crates/nu-command/src/math/floor.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathFloor; -impl Command for SubCommand { +impl Command for MathFloor { fn name(&self) -> &str { "math floor" } @@ -103,6 +103,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathFloor {}) } } diff --git a/crates/nu-command/src/math/log.rs b/crates/nu-command/src/math/log.rs index daf231a497..79eed71640 100644 --- a/crates/nu-command/src/math/log.rs +++ b/crates/nu-command/src/math/log.rs @@ -2,9 +2,9 @@ use nu_engine::command_prelude::*; use nu_protocol::Signals; #[derive(Clone)] -pub struct SubCommand; +pub struct MathLog; -impl Command for SubCommand { +impl Command for MathLog { fn name(&self) -> &str { "math log" } @@ -159,6 +159,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathLog {}) } } diff --git a/crates/nu-command/src/math/max.rs b/crates/nu-command/src/math/max.rs index 2ee7f89b15..1cbd5e555e 100644 --- a/crates/nu-command/src/math/max.rs +++ b/crates/nu-command/src/math/max.rs @@ -5,9 +5,9 @@ use crate::math::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathMax; -impl Command for SubCommand { +impl Command for MathMax { fn name(&self) -> &str { "math max" } @@ -97,6 +97,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathMax {}) } } diff --git a/crates/nu-command/src/math/median.rs b/crates/nu-command/src/math/median.rs index 7b88fab346..ae1471cadf 100644 --- a/crates/nu-command/src/math/median.rs +++ b/crates/nu-command/src/math/median.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use std::cmp::Ordering; #[derive(Clone)] -pub struct SubCommand; +pub struct MathMedian; -impl Command for SubCommand { +impl Command for MathMedian { fn name(&self) -> &str { "math median" } @@ -151,6 +151,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathMedian {}) } } diff --git a/crates/nu-command/src/math/min.rs b/crates/nu-command/src/math/min.rs index 6722575579..85d1de68f1 100644 --- a/crates/nu-command/src/math/min.rs +++ b/crates/nu-command/src/math/min.rs @@ -5,9 +5,9 @@ use crate::math::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathMin; -impl Command for SubCommand { +impl Command for MathMin { fn name(&self) -> &str { "math min" } @@ -95,6 +95,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathMin {}) } } diff --git a/crates/nu-command/src/math/mod.rs b/crates/nu-command/src/math/mod.rs index 97828c8b86..b0e1c68f2f 100644 --- a/crates/nu-command/src/math/mod.rs +++ b/crates/nu-command/src/math/mod.rs @@ -17,20 +17,20 @@ mod sum; mod utils; mod variance; -pub use abs::SubCommand as MathAbs; -pub use avg::SubCommand as MathAvg; -pub use ceil::SubCommand as MathCeil; -pub use floor::SubCommand as MathFloor; +pub use abs::MathAbs; +pub use avg::MathAvg; +pub use ceil::MathCeil; +pub use floor::MathFloor; pub use math_::MathCommand as Math; -pub use max::SubCommand as MathMax; -pub use median::SubCommand as MathMedian; -pub use min::SubCommand as MathMin; -pub use mode::SubCommand as MathMode; -pub use product::SubCommand as MathProduct; -pub use round::SubCommand as MathRound; -pub use sqrt::SubCommand as MathSqrt; -pub use stddev::SubCommand as MathStddev; -pub use sum::SubCommand as MathSum; -pub use variance::SubCommand as MathVariance; +pub use max::MathMax; +pub use median::MathMedian; +pub use min::MathMin; +pub use mode::MathMode; +pub use product::MathProduct; +pub use round::MathRound; +pub use sqrt::MathSqrt; +pub use stddev::MathStddev; +pub use sum::MathSum; +pub use variance::MathVariance; -pub use self::log::SubCommand as MathLog; +pub use log::MathLog; diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index 6f42d0bfd5..5183a855a9 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -3,7 +3,7 @@ use nu_engine::command_prelude::*; use std::{cmp::Ordering, collections::HashMap}; #[derive(Clone)] -pub struct SubCommand; +pub struct MathMode; #[derive(Hash, Eq, PartialEq, Debug)] enum NumberTypes { @@ -28,7 +28,7 @@ impl HashableType { } } -impl Command for SubCommand { +impl Command for MathMode { fn name(&self) -> &str { "math mode" } @@ -183,6 +183,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathMode {}) } } diff --git a/crates/nu-command/src/math/product.rs b/crates/nu-command/src/math/product.rs index 41e100b154..c4560601aa 100644 --- a/crates/nu-command/src/math/product.rs +++ b/crates/nu-command/src/math/product.rs @@ -5,9 +5,9 @@ use crate::math::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathProduct; -impl Command for SubCommand { +impl Command for MathProduct { fn name(&self) -> &str { "math product" } @@ -88,6 +88,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathProduct {}) } } diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index aeb92002c0..558715e675 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathRound; -impl Command for SubCommand { +impl Command for MathRound { fn name(&self) -> &str { "math round" } @@ -153,6 +153,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathRound {}) } } diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index b8f982a540..38b2a4d800 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathSqrt; -impl Command for SubCommand { +impl Command for MathSqrt { fn name(&self) -> &str { "math sqrt" } @@ -127,6 +127,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathSqrt {}) } } diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index 1e10cedf41..051f7d02d7 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -3,9 +3,9 @@ use crate::math::utils::run_with_function; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathStddev; -impl Command for SubCommand { +impl Command for MathStddev { fn name(&self) -> &str { "math stddev" } @@ -111,6 +111,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathStddev {}) } } diff --git a/crates/nu-command/src/math/sum.rs b/crates/nu-command/src/math/sum.rs index 30bc71bb7a..8cae85c3a8 100644 --- a/crates/nu-command/src/math/sum.rs +++ b/crates/nu-command/src/math/sum.rs @@ -5,9 +5,9 @@ use crate::math::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathSum; -impl Command for SubCommand { +impl Command for MathSum { fn name(&self) -> &str { "math sum" } @@ -94,6 +94,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathSum {}) } } diff --git a/crates/nu-command/src/math/variance.rs b/crates/nu-command/src/math/variance.rs index 91128e36cd..b221d92746 100644 --- a/crates/nu-command/src/math/variance.rs +++ b/crates/nu-command/src/math/variance.rs @@ -2,9 +2,9 @@ use crate::math::utils::run_with_function; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct MathVariance; -impl Command for SubCommand { +impl Command for MathVariance { fn name(&self) -> &str { "math variance" } @@ -135,6 +135,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(MathVariance {}) } } diff --git a/crates/nu-command/src/network/http/delete.rs b/crates/nu-command/src/network/http/delete.rs index 8a931f3653..f46c16b584 100644 --- a/crates/nu-command/src/network/http/delete.rs +++ b/crates/nu-command/src/network/http/delete.rs @@ -6,9 +6,9 @@ use crate::network::http::client::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpDelete; -impl Command for SubCommand { +impl Command for HttpDelete { fn name(&self) -> &str { "http delete" } @@ -248,6 +248,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpDelete {}) } } diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index 245ba3747c..f317b4b080 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -8,9 +8,9 @@ use nu_engine::command_prelude::*; use super::client::HttpBody; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpGet; -impl Command for SubCommand { +impl Command for HttpGet { fn name(&self) -> &str { "http get" } @@ -216,6 +216,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpGet {}) } } diff --git a/crates/nu-command/src/network/http/head.rs b/crates/nu-command/src/network/http/head.rs index 4245d77abd..5298fefda8 100644 --- a/crates/nu-command/src/network/http/head.rs +++ b/crates/nu-command/src/network/http/head.rs @@ -8,9 +8,9 @@ use nu_engine::command_prelude::*; use nu_protocol::Signals; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpHead; -impl Command for SubCommand { +impl Command for HttpHead { fn name(&self) -> &str { "http head" } @@ -175,6 +175,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpHead {}) } } diff --git a/crates/nu-command/src/network/http/mod.rs b/crates/nu-command/src/network/http/mod.rs index 91fcb86b5e..7e13c53501 100644 --- a/crates/nu-command/src/network/http/mod.rs +++ b/crates/nu-command/src/network/http/mod.rs @@ -8,11 +8,11 @@ mod patch; mod post; mod put; -pub use delete::SubCommand as HttpDelete; -pub use get::SubCommand as HttpGet; -pub use head::SubCommand as HttpHead; +pub use delete::HttpDelete; +pub use get::HttpGet; +pub use head::HttpHead; pub use http_::Http; -pub use options::SubCommand as HttpOptions; -pub use patch::SubCommand as HttpPatch; -pub use post::SubCommand as HttpPost; -pub use put::SubCommand as HttpPut; +pub use options::HttpOptions; +pub use patch::HttpPatch; +pub use post::HttpPost; +pub use put::HttpPut; diff --git a/crates/nu-command/src/network/http/options.rs b/crates/nu-command/src/network/http/options.rs index c8ee91d530..75a459cb9b 100644 --- a/crates/nu-command/src/network/http/options.rs +++ b/crates/nu-command/src/network/http/options.rs @@ -7,9 +7,9 @@ use nu_engine::command_prelude::*; use super::client::HttpBody; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpOptions; -impl Command for SubCommand { +impl Command for HttpOptions { fn name(&self) -> &str { "http options" } @@ -197,6 +197,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpOptions {}) } } diff --git a/crates/nu-command/src/network/http/patch.rs b/crates/nu-command/src/network/http/patch.rs index e3db71d3b1..ee8143650a 100644 --- a/crates/nu-command/src/network/http/patch.rs +++ b/crates/nu-command/src/network/http/patch.rs @@ -6,9 +6,9 @@ use crate::network::http::client::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpPatch; -impl Command for SubCommand { +impl Command for HttpPatch { fn name(&self) -> &str { "http patch" } @@ -250,6 +250,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpPatch {}) } } diff --git a/crates/nu-command/src/network/http/post.rs b/crates/nu-command/src/network/http/post.rs index 5a23765366..8c2a3edb9d 100644 --- a/crates/nu-command/src/network/http/post.rs +++ b/crates/nu-command/src/network/http/post.rs @@ -6,9 +6,9 @@ use crate::network::http::client::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpPost; -impl Command for SubCommand { +impl Command for HttpPost { fn name(&self) -> &str { "http post" } @@ -258,6 +258,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpPost {}) } } diff --git a/crates/nu-command/src/network/http/put.rs b/crates/nu-command/src/network/http/put.rs index a1c2aa71a3..69adaa9aba 100644 --- a/crates/nu-command/src/network/http/put.rs +++ b/crates/nu-command/src/network/http/put.rs @@ -6,9 +6,9 @@ use crate::network::http::client::{ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct HttpPut; -impl Command for SubCommand { +impl Command for HttpPut { fn name(&self) -> &str { "http put" } @@ -249,6 +249,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(HttpPut {}) } } diff --git a/crates/nu-command/src/network/mod.rs b/crates/nu-command/src/network/mod.rs index 2366fde594..ca6f850155 100644 --- a/crates/nu-command/src/network/mod.rs +++ b/crates/nu-command/src/network/mod.rs @@ -11,7 +11,7 @@ pub use self::http::*; pub use self::url::*; #[cfg(feature = "network")] -pub use port::SubCommand as Port; +pub use port::Port; #[cfg(feature = "network")] pub use version_check::VersionCheck; diff --git a/crates/nu-command/src/network/port.rs b/crates/nu-command/src/network/port.rs index fe3c987b85..28d52c07f0 100644 --- a/crates/nu-command/src/network/port.rs +++ b/crates/nu-command/src/network/port.rs @@ -4,9 +4,9 @@ use nu_protocol::shell_error::io::IoError; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener}; #[derive(Clone)] -pub struct SubCommand; +pub struct Port; -impl Command for SubCommand { +impl Command for Port { fn name(&self) -> &str { "port" } diff --git a/crates/nu-command/src/network/url/build_query.rs b/crates/nu-command/src/network/url/build_query.rs index e11f476469..aaf96296e9 100644 --- a/crates/nu-command/src/network/url/build_query.rs +++ b/crates/nu-command/src/network/url/build_query.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use super::query::{record_to_query_string, table_to_query_string}; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlBuildQuery; -impl Command for SubCommand { +impl Command for UrlBuildQuery { fn name(&self) -> &str { "url build-query" } @@ -90,6 +90,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlBuildQuery {}) } } diff --git a/crates/nu-command/src/network/url/decode.rs b/crates/nu-command/src/network/url/decode.rs index 8db5d09b15..312116f254 100644 --- a/crates/nu-command/src/network/url/decode.rs +++ b/crates/nu-command/src/network/url/decode.rs @@ -4,9 +4,9 @@ use nu_engine::command_prelude::*; use percent_encoding::percent_decode_str; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlDecode; -impl Command for SubCommand { +impl Command for UrlDecode { fn name(&self) -> &str { "url decode" } @@ -114,6 +114,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlDecode {}) } } diff --git a/crates/nu-command/src/network/url/encode.rs b/crates/nu-command/src/network/url/encode.rs index 3854e0b401..f0064f94d5 100644 --- a/crates/nu-command/src/network/url/encode.rs +++ b/crates/nu-command/src/network/url/encode.rs @@ -4,9 +4,9 @@ use nu_engine::command_prelude::*; use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC}; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlEncode; -impl Command for SubCommand { +impl Command for UrlEncode { fn name(&self) -> &str { "url encode" } @@ -130,6 +130,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlEncode {}) } } diff --git a/crates/nu-command/src/network/url/join.rs b/crates/nu-command/src/network/url/join.rs index b8e120134a..d6a8c65648 100644 --- a/crates/nu-command/src/network/url/join.rs +++ b/crates/nu-command/src/network/url/join.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use super::query::{record_to_query_string, table_to_query_string}; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlJoin; -impl Command for SubCommand { +impl Command for UrlJoin { fn name(&self) -> &str { "url join" } @@ -378,6 +378,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlJoin {}) } } diff --git a/crates/nu-command/src/network/url/mod.rs b/crates/nu-command/src/network/url/mod.rs index 35221e6291..e833d66d81 100644 --- a/crates/nu-command/src/network/url/mod.rs +++ b/crates/nu-command/src/network/url/mod.rs @@ -7,10 +7,10 @@ mod query; mod split_query; mod url_; -pub use self::parse::SubCommand as UrlParse; -pub use build_query::SubCommand as UrlBuildQuery; -pub use decode::SubCommand as UrlDecode; -pub use encode::SubCommand as UrlEncode; -pub use join::SubCommand as UrlJoin; -pub use split_query::SubCommand as UrlSplitQuery; +pub use self::parse::UrlParse; +pub use build_query::UrlBuildQuery; +pub use decode::UrlDecode; +pub use encode::UrlEncode; +pub use join::UrlJoin; +pub use split_query::UrlSplitQuery; pub use url_::Url; diff --git a/crates/nu-command/src/network/url/parse.rs b/crates/nu-command/src/network/url/parse.rs index c4d8caefe0..9987eb265f 100644 --- a/crates/nu-command/src/network/url/parse.rs +++ b/crates/nu-command/src/network/url/parse.rs @@ -5,9 +5,9 @@ use url::Url; use super::query::query_string_to_table; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlParse; -impl Command for SubCommand { +impl Command for UrlParse { fn name(&self) -> &str { "url parse" } @@ -128,6 +128,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlParse {}) } } diff --git a/crates/nu-command/src/network/url/split_query.rs b/crates/nu-command/src/network/url/split_query.rs index 3fbe282515..f400e921b4 100644 --- a/crates/nu-command/src/network/url/split_query.rs +++ b/crates/nu-command/src/network/url/split_query.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use super::query::query_string_to_table; #[derive(Clone)] -pub struct SubCommand; +pub struct UrlSplitQuery; -impl Command for SubCommand { +impl Command for UrlSplitQuery { fn name(&self) -> &str { "url split-query" } @@ -101,6 +101,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(UrlSplitQuery {}) } } diff --git a/crates/nu-command/src/path/basename.rs b/crates/nu-command/src/path/basename.rs index d619a54c34..977ff6c8e2 100644 --- a/crates/nu-command/src/path/basename.rs +++ b/crates/nu-command/src/path/basename.rs @@ -10,9 +10,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathBasename; -impl Command for SubCommand { +impl Command for PathBasename { fn name(&self) -> &str { "path basename" } @@ -156,6 +156,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathBasename {}) } } diff --git a/crates/nu-command/src/path/dirname.rs b/crates/nu-command/src/path/dirname.rs index 3a3a1604e5..f64449d504 100644 --- a/crates/nu-command/src/path/dirname.rs +++ b/crates/nu-command/src/path/dirname.rs @@ -11,9 +11,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathDirname; -impl Command for SubCommand { +impl Command for PathDirname { fn name(&self) -> &str { "path dirname" } @@ -194,6 +194,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathDirname {}) } } diff --git a/crates/nu-command/src/path/exists.rs b/crates/nu-command/src/path/exists.rs index 0c482a5fe5..d90800f518 100644 --- a/crates/nu-command/src/path/exists.rs +++ b/crates/nu-command/src/path/exists.rs @@ -13,9 +13,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathExists; -impl Command for SubCommand { +impl Command for PathExists { fn name(&self) -> &str { "path exists" } @@ -167,6 +167,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathExists {}) } } diff --git a/crates/nu-command/src/path/expand.rs b/crates/nu-command/src/path/expand.rs index cea1282b9a..ff6728211e 100644 --- a/crates/nu-command/src/path/expand.rs +++ b/crates/nu-command/src/path/expand.rs @@ -17,9 +17,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathExpand; -impl Command for SubCommand { +impl Command for PathExpand { fn name(&self) -> &str { "path expand" } @@ -197,6 +197,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathExpand {}) } } diff --git a/crates/nu-command/src/path/join.rs b/crates/nu-command/src/path/join.rs index 2d537f6822..9f055589d3 100644 --- a/crates/nu-command/src/path/join.rs +++ b/crates/nu-command/src/path/join.rs @@ -10,9 +10,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathJoin; -impl Command for SubCommand { +impl Command for PathJoin { fn name(&self) -> &str { "path join" } @@ -299,6 +299,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathJoin {}) } } diff --git a/crates/nu-command/src/path/mod.rs b/crates/nu-command/src/path/mod.rs index 4b6405c8d8..d6f3a19528 100644 --- a/crates/nu-command/src/path/mod.rs +++ b/crates/nu-command/src/path/mod.rs @@ -10,17 +10,17 @@ mod self_; mod split; mod r#type; -pub use basename::SubCommand as PathBasename; -pub use dirname::SubCommand as PathDirname; -pub use exists::SubCommand as PathExists; -pub use expand::SubCommand as PathExpand; -pub use join::SubCommand as PathJoin; -pub use parse::SubCommand as PathParse; -pub use path_::PathCommand as Path; -pub use r#type::SubCommand as PathType; -pub use relative_to::SubCommand as PathRelativeTo; -pub use self_::SubCommand as PathSelf; -pub use split::SubCommand as PathSplit; +pub use basename::PathBasename; +pub use dirname::PathDirname; +pub use exists::PathExists; +pub use expand::PathExpand; +pub use join::PathJoin; +pub use parse::PathParse; +pub use path_::Path; +pub use r#type::PathType; +pub use relative_to::PathRelativeTo; +pub use self_::PathSelf; +pub use split::PathSplit; use nu_protocol::{ShellError, Span, Value}; use std::path::Path as StdPath; diff --git a/crates/nu-command/src/path/parse.rs b/crates/nu-command/src/path/parse.rs index c41bfeff1a..8025c1fcdd 100644 --- a/crates/nu-command/src/path/parse.rs +++ b/crates/nu-command/src/path/parse.rs @@ -10,9 +10,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathParse; -impl Command for SubCommand { +impl Command for PathParse { fn name(&self) -> &str { "path parse" } @@ -252,6 +252,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathParse {}) } } diff --git a/crates/nu-command/src/path/path_.rs b/crates/nu-command/src/path/path_.rs index bb2b46fb38..7c3fa4e24d 100644 --- a/crates/nu-command/src/path/path_.rs +++ b/crates/nu-command/src/path/path_.rs @@ -1,9 +1,9 @@ use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] -pub struct PathCommand; +pub struct Path; -impl Command for PathCommand { +impl Command for Path { fn name(&self) -> &str { "path" } diff --git a/crates/nu-command/src/path/relative_to.rs b/crates/nu-command/src/path/relative_to.rs index 71cfa8b2a9..d63c3e2bb0 100644 --- a/crates/nu-command/src/path/relative_to.rs +++ b/crates/nu-command/src/path/relative_to.rs @@ -11,9 +11,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathRelativeTo; -impl Command for SubCommand { +impl Command for PathRelativeTo { fn name(&self) -> &str { "path relative-to" } @@ -166,6 +166,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathRelativeTo {}) } } diff --git a/crates/nu-command/src/path/self_.rs b/crates/nu-command/src/path/self_.rs index 49c1de8624..4ed74dce16 100644 --- a/crates/nu-command/src/path/self_.rs +++ b/crates/nu-command/src/path/self_.rs @@ -3,9 +3,9 @@ use nu_path::expand_path_with; use nu_protocol::{engine::StateWorkingSet, shell_error::io::IoError}; #[derive(Clone)] -pub struct SubCommand; +pub struct PathSelf; -impl Command for SubCommand { +impl Command for PathSelf { fn name(&self) -> &str { "path self" } @@ -126,6 +126,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathSelf {}) } } diff --git a/crates/nu-command/src/path/split.rs b/crates/nu-command/src/path/split.rs index 727e99b024..106ec044b2 100644 --- a/crates/nu-command/src/path/split.rs +++ b/crates/nu-command/src/path/split.rs @@ -8,9 +8,9 @@ struct Arguments; impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathSplit; -impl Command for SubCommand { +impl Command for PathSplit { fn name(&self) -> &str { "path split" } @@ -193,6 +193,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathSplit {}) } } diff --git a/crates/nu-command/src/path/type.rs b/crates/nu-command/src/path/type.rs index 6abed1319a..bdd5d49966 100644 --- a/crates/nu-command/src/path/type.rs +++ b/crates/nu-command/src/path/type.rs @@ -11,9 +11,9 @@ struct Arguments { impl PathSubcommandArguments for Arguments {} #[derive(Clone)] -pub struct SubCommand; +pub struct PathType; -impl Command for SubCommand { +impl Command for PathType { fn name(&self) -> &str { "path type" } @@ -147,6 +147,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(PathType {}) } } diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs index 143bbc9ac1..fb25361764 100644 --- a/crates/nu-command/src/platform/ansi/ansi_.rs +++ b/crates/nu-command/src/platform/ansi/ansi_.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use std::sync::LazyLock; #[derive(Clone)] -pub struct AnsiCommand; +pub struct Ansi; struct AnsiCode { short_name: Option<&'static str>, @@ -505,7 +505,7 @@ static CODE_LIST: LazyLock> = LazyLock::new(|| { vec![ static CODE_MAP: LazyLock> = LazyLock::new(|| build_ansi_hashmap(&CODE_LIST)); -impl Command for AnsiCommand { +impl Command for Ansi { fn name(&self) -> &str { "ansi" } @@ -902,12 +902,12 @@ fn build_ansi_hashmap(v: &[AnsiCode]) -> HashMap<&str, &str> { #[cfg(test)] mod tests { - use crate::platform::ansi::ansi_::AnsiCommand; + use crate::platform::ansi::ansi_::Ansi; #[test] fn examples_work_as_expected() { use crate::test_examples; - test_examples(AnsiCommand {}) + test_examples(Ansi {}) } } diff --git a/crates/nu-command/src/platform/ansi/link.rs b/crates/nu-command/src/platform/ansi/link.rs index 4e86f76236..9dada27bed 100644 --- a/crates/nu-command/src/platform/ansi/link.rs +++ b/crates/nu-command/src/platform/ansi/link.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct AnsiLink; -impl Command for SubCommand { +impl Command for AnsiLink { fn name(&self) -> &str { "ansi link" } @@ -144,12 +144,12 @@ fn add_osc_link(text: &str, link: &str) -> String { #[cfg(test)] mod tests { - use super::SubCommand; + use super::AnsiLink; #[test] fn examples_work_as_expected() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(AnsiLink {}) } } diff --git a/crates/nu-command/src/platform/ansi/mod.rs b/crates/nu-command/src/platform/ansi/mod.rs index a8eb5bfa93..dd130a9a64 100644 --- a/crates/nu-command/src/platform/ansi/mod.rs +++ b/crates/nu-command/src/platform/ansi/mod.rs @@ -2,6 +2,6 @@ mod ansi_; mod link; mod strip; -pub use ansi_::AnsiCommand as Ansi; -pub use link::SubCommand as AnsiLink; -pub use strip::SubCommand as AnsiStrip; +pub use ansi_::Ansi; +pub use link::AnsiLink; +pub use strip::AnsiStrip; diff --git a/crates/nu-command/src/platform/ansi/strip.rs b/crates/nu-command/src/platform/ansi/strip.rs index 23063cff63..67eb894e96 100644 --- a/crates/nu-command/src/platform/ansi/strip.rs +++ b/crates/nu-command/src/platform/ansi/strip.rs @@ -16,9 +16,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct AnsiStrip; -impl Command for SubCommand { +impl Command for AnsiStrip { fn name(&self) -> &str { "ansi strip" } @@ -83,14 +83,14 @@ fn action(input: &Value, args: &Arguments, _span: Span) -> Value { #[cfg(test)] mod tests { - use super::{action, Arguments, SubCommand}; + use super::{action, AnsiStrip, Arguments}; use nu_protocol::{engine::EngineState, Span, Value}; #[test] fn examples_work_as_expected() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(AnsiStrip {}) } #[test] diff --git a/crates/nu-command/src/random/binary.rs b/crates/nu-command/src/random/binary.rs index 726b1000d7..47e6429eba 100644 --- a/crates/nu-command/src/random/binary.rs +++ b/crates/nu-command/src/random/binary.rs @@ -2,9 +2,9 @@ use nu_engine::command_prelude::*; use rand::{thread_rng, RngCore}; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomBinary; -impl Command for SubCommand { +impl Command for RandomBinary { fn name(&self) -> &str { "random binary" } @@ -89,6 +89,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomBinary {}) } } diff --git a/crates/nu-command/src/random/bool.rs b/crates/nu-command/src/random/bool.rs index a2f13d337c..51870a7836 100644 --- a/crates/nu-command/src/random/bool.rs +++ b/crates/nu-command/src/random/bool.rs @@ -3,9 +3,9 @@ use nu_engine::command_prelude::*; use rand::prelude::{thread_rng, Rng}; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomBool; -impl Command for SubCommand { +impl Command for RandomBool { fn name(&self) -> &str { "random bool" } @@ -91,6 +91,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomBool {}) } } diff --git a/crates/nu-command/src/random/chars.rs b/crates/nu-command/src/random/chars.rs index 975f0f0c76..5ef76603b7 100644 --- a/crates/nu-command/src/random/chars.rs +++ b/crates/nu-command/src/random/chars.rs @@ -7,9 +7,9 @@ use rand::{ const DEFAULT_CHARS_LENGTH: usize = 25; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomChars; -impl Command for SubCommand { +impl Command for RandomChars { fn name(&self) -> &str { "random chars" } @@ -119,6 +119,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomChars {}) } } diff --git a/crates/nu-command/src/random/dice.rs b/crates/nu-command/src/random/dice.rs index 32768a9937..c9720e49bb 100644 --- a/crates/nu-command/src/random/dice.rs +++ b/crates/nu-command/src/random/dice.rs @@ -3,9 +3,9 @@ use nu_protocol::ListStream; use rand::prelude::{thread_rng, Rng}; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomDice; -impl Command for SubCommand { +impl Command for RandomDice { fn name(&self) -> &str { "random dice" } @@ -89,6 +89,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomDice {}) } } diff --git a/crates/nu-command/src/random/float.rs b/crates/nu-command/src/random/float.rs index ad2c39e069..fb7cc329b4 100644 --- a/crates/nu-command/src/random/float.rs +++ b/crates/nu-command/src/random/float.rs @@ -4,9 +4,9 @@ use rand::prelude::{thread_rng, Rng}; use std::ops::Bound; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomFloat; -impl Command for SubCommand { +impl Command for RandomFloat { fn name(&self) -> &str { "random float" } @@ -112,6 +112,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomFloat {}) } } diff --git a/crates/nu-command/src/random/int.rs b/crates/nu-command/src/random/int.rs index 461ed2090c..2adff1ec70 100644 --- a/crates/nu-command/src/random/int.rs +++ b/crates/nu-command/src/random/int.rs @@ -4,9 +4,9 @@ use rand::prelude::{thread_rng, Rng}; use std::ops::Bound; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomInt; -impl Command for SubCommand { +impl Command for RandomInt { fn name(&self) -> &str { "random int" } @@ -124,6 +124,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomInt {}) } } diff --git a/crates/nu-command/src/random/mod.rs b/crates/nu-command/src/random/mod.rs index 4c05376c88..43c8af862f 100644 --- a/crates/nu-command/src/random/mod.rs +++ b/crates/nu-command/src/random/mod.rs @@ -7,11 +7,11 @@ mod int; mod random_; mod uuid; -pub use self::binary::SubCommand as RandomBinary; -pub use self::bool::SubCommand as RandomBool; -pub use self::chars::SubCommand as RandomChars; -pub use self::dice::SubCommand as RandomDice; -pub use self::float::SubCommand as RandomFloat; -pub use self::int::SubCommand as RandomInt; -pub use self::uuid::SubCommand as RandomUuid; -pub use random_::RandomCommand as Random; +pub use self::binary::RandomBinary; +pub use self::bool::RandomBool; +pub use self::chars::RandomChars; +pub use self::dice::RandomDice; +pub use self::float::RandomFloat; +pub use self::int::RandomInt; +pub use self::uuid::RandomUuid; +pub use random_::Random; diff --git a/crates/nu-command/src/random/random_.rs b/crates/nu-command/src/random/random_.rs index e9159e242a..1586fbb918 100644 --- a/crates/nu-command/src/random/random_.rs +++ b/crates/nu-command/src/random/random_.rs @@ -1,9 +1,9 @@ use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] -pub struct RandomCommand; +pub struct Random; -impl Command for RandomCommand { +impl Command for Random { fn name(&self) -> &str { "random" } diff --git a/crates/nu-command/src/random/uuid.rs b/crates/nu-command/src/random/uuid.rs index ab8820367c..48b2df8ee4 100644 --- a/crates/nu-command/src/random/uuid.rs +++ b/crates/nu-command/src/random/uuid.rs @@ -2,9 +2,9 @@ use nu_engine::command_prelude::*; use uuid::{Timestamp, Uuid}; #[derive(Clone)] -pub struct SubCommand; +pub struct RandomUuid; -impl Command for SubCommand { +impl Command for RandomUuid { fn name(&self) -> &str { "random uuid" } @@ -333,6 +333,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(RandomUuid {}) } } diff --git a/crates/nu-command/src/removed/format.rs b/crates/nu-command/src/removed/format.rs index 84083b037b..791d3f28f5 100644 --- a/crates/nu-command/src/removed/format.rs +++ b/crates/nu-command/src/removed/format.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct DateFormat; -impl Command for SubCommand { +impl Command for DateFormat { fn name(&self) -> &str { "date format" } diff --git a/crates/nu-command/src/removed/mod.rs b/crates/nu-command/src/removed/mod.rs index 5ea783d9ca..5b7ac39522 100644 --- a/crates/nu-command/src/removed/mod.rs +++ b/crates/nu-command/src/removed/mod.rs @@ -2,6 +2,6 @@ mod format; mod let_env; mod removed_commands; -pub use format::SubCommand as DateFormat; +pub use format::DateFormat; pub use let_env::LetEnv; pub use removed_commands::*; diff --git a/crates/nu-command/src/strings/split/chars.rs b/crates/nu-command/src/strings/split/chars.rs index ac71121645..c40bdffa6e 100644 --- a/crates/nu-command/src/strings/split/chars.rs +++ b/crates/nu-command/src/strings/split/chars.rs @@ -4,9 +4,9 @@ use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] -pub struct SubCommand; +pub struct SplitChars; -impl Command for SubCommand { +impl Command for SplitChars { fn name(&self) -> &str { "split chars" } @@ -173,6 +173,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(SplitChars {}) } } diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index 3f355a43c0..663ffff876 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -2,9 +2,9 @@ use fancy_regex::{escape, Regex}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct SplitColumn; -impl Command for SubCommand { +impl Command for SplitColumn { fn name(&self) -> &str { "split column" } @@ -275,6 +275,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(SplitColumn {}) } } diff --git a/crates/nu-command/src/strings/split/command.rs b/crates/nu-command/src/strings/split/command.rs index 8f76f30a18..bf438638d1 100644 --- a/crates/nu-command/src/strings/split/command.rs +++ b/crates/nu-command/src/strings/split/command.rs @@ -1,9 +1,9 @@ use nu_engine::{command_prelude::*, get_full_help}; #[derive(Clone)] -pub struct SplitCommand; +pub struct Split; -impl Command for SplitCommand { +impl Command for Split { fn name(&self) -> &str { "split" } diff --git a/crates/nu-command/src/strings/split/mod.rs b/crates/nu-command/src/strings/split/mod.rs index 878641540e..f0dfabe198 100644 --- a/crates/nu-command/src/strings/split/mod.rs +++ b/crates/nu-command/src/strings/split/mod.rs @@ -5,9 +5,9 @@ mod list; mod row; mod words; -pub use chars::SubCommand as SplitChars; -pub use column::SubCommand as SplitColumn; -pub use command::SplitCommand as Split; +pub use chars::SplitChars; +pub use column::SplitColumn; +pub use command::Split; pub use list::SubCommand as SplitList; -pub use row::SubCommand as SplitRow; -pub use words::SubCommand as SplitWords; +pub use row::SplitRow; +pub use words::SplitWords; diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index 939ac1cc7f..d1a16e7c7e 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -2,9 +2,9 @@ use fancy_regex::{escape, Regex}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct SplitRow; -impl Command for SubCommand { +impl Command for SplitRow { fn name(&self) -> &str { "split row" } @@ -239,6 +239,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(SplitRow {}) } } diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index 9d392302c2..0aa02b5e93 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -5,9 +5,9 @@ use nu_engine::command_prelude::*; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] -pub struct SubCommand; +pub struct SplitWords; -impl Command for SubCommand { +impl Command for SplitWords { fn name(&self) -> &str { "split words" } @@ -420,7 +420,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(SplitWords {}) } #[test] fn mixed_letter_number() { diff --git a/crates/nu-command/src/strings/str_/case/capitalize.rs b/crates/nu-command/src/strings/str_/case/capitalize.rs index 545385a13c..8bcb690566 100644 --- a/crates/nu-command/src/strings/str_/case/capitalize.rs +++ b/crates/nu-command/src/strings/str_/case/capitalize.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrCapitalize; -impl Command for SubCommand { +impl Command for StrCapitalize { fn name(&self) -> &str { "str capitalize" } @@ -145,6 +145,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrCapitalize {}) } } diff --git a/crates/nu-command/src/strings/str_/case/downcase.rs b/crates/nu-command/src/strings/str_/case/downcase.rs index 72c6619fc3..58854436ea 100644 --- a/crates/nu-command/src/strings/str_/case/downcase.rs +++ b/crates/nu-command/src/strings/str_/case/downcase.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrDowncase; -impl Command for SubCommand { +impl Command for StrDowncase { fn name(&self) -> &str { "str downcase" } @@ -143,6 +143,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrDowncase {}) } } diff --git a/crates/nu-command/src/strings/str_/case/mod.rs b/crates/nu-command/src/strings/str_/case/mod.rs index 3390ff097e..5fed0ad2e6 100644 --- a/crates/nu-command/src/strings/str_/case/mod.rs +++ b/crates/nu-command/src/strings/str_/case/mod.rs @@ -3,10 +3,10 @@ mod downcase; mod str_; mod upcase; -pub use capitalize::SubCommand as StrCapitalize; -pub use downcase::SubCommand as StrDowncase; +pub use capitalize::StrCapitalize; +pub use downcase::StrDowncase; pub use str_::Str; -pub use upcase::SubCommand as StrUpcase; +pub use upcase::StrUpcase; use nu_cmd_base::input_handler::{operate as general_operate, CmdArgument}; use nu_engine::command_prelude::*; diff --git a/crates/nu-command/src/strings/str_/case/upcase.rs b/crates/nu-command/src/strings/str_/case/upcase.rs index 0fe46ce4e7..3eb554cef0 100644 --- a/crates/nu-command/src/strings/str_/case/upcase.rs +++ b/crates/nu-command/src/strings/str_/case/upcase.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrUpcase; -impl Command for SubCommand { +impl Command for StrUpcase { fn name(&self) -> &str { "str upcase" } @@ -116,13 +116,13 @@ fn action(input: &Value, head: Span) -> Value { #[cfg(test)] mod tests { use super::*; - use super::{action, SubCommand}; + use super::{action, StrUpcase}; #[test] fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrUpcase {}) } #[test] diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index d24fac6668..5e500f95fb 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -4,7 +4,7 @@ use nu_engine::command_prelude::*; use nu_utils::IgnoreCaseExt; #[derive(Clone)] -pub struct SubCommand; +pub struct StrContains; struct Arguments { substring: String, @@ -18,7 +18,7 @@ impl CmdArgument for Arguments { } } -impl Command for SubCommand { +impl Command for StrContains { fn name(&self) -> &str { "str contains" } @@ -187,6 +187,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrContains {}) } } diff --git a/crates/nu-command/src/strings/str_/distance.rs b/crates/nu-command/src/strings/str_/distance.rs index ce54abcbe4..e6a286b551 100644 --- a/crates/nu-command/src/strings/str_/distance.rs +++ b/crates/nu-command/src/strings/str_/distance.rs @@ -3,7 +3,7 @@ use nu_engine::command_prelude::*; use nu_protocol::{engine::StateWorkingSet, levenshtein_distance}; #[derive(Clone)] -pub struct SubCommand; +pub struct StrDistance; struct Arguments { compare_string: String, @@ -16,7 +16,7 @@ impl CmdArgument for Arguments { } } -impl Command for SubCommand { +impl Command for StrDistance { fn name(&self) -> &str { "str distance" } @@ -148,6 +148,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrDistance {}) } } diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index bb70a919e8..b23a11dca8 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -16,9 +16,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct StrEndswith; -impl Command for SubCommand { +impl Command for StrEndswith { fn name(&self) -> &str { "str ends-with" } @@ -149,6 +149,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrEndswith {}) } } diff --git a/crates/nu-command/src/strings/str_/expand.rs b/crates/nu-command/src/strings/str_/expand.rs index ea98f887ad..ab4cb7e67f 100644 --- a/crates/nu-command/src/strings/str_/expand.rs +++ b/crates/nu-command/src/strings/str_/expand.rs @@ -1,9 +1,9 @@ use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrExpand; -impl Command for SubCommand { +impl Command for StrExpand { fn name(&self) -> &str { "str expand" } @@ -377,6 +377,6 @@ mod tests { #[test] fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrExpand {}) } } diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index efd9540158..da98248582 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -21,9 +21,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct StrIndexOf; -impl Command for SubCommand { +impl Command for StrIndexOf { fn name(&self) -> &str { "str index-of" } @@ -246,13 +246,13 @@ mod tests { use nu_protocol::ast::RangeInclusion; use super::*; - use super::{action, Arguments, SubCommand}; + use super::{action, Arguments, StrIndexOf}; #[test] fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrIndexOf {}) } #[test] diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index ca1313e710..f5eedd29ae 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -16,9 +16,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct StrLength; -impl Command for SubCommand { +impl Command for StrLength { fn name(&self) -> &str { "str length" } @@ -177,6 +177,6 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrLength {}) } } diff --git a/crates/nu-command/src/strings/str_/mod.rs b/crates/nu-command/src/strings/str_/mod.rs index fb34ace833..a1db758d94 100644 --- a/crates/nu-command/src/strings/str_/mod.rs +++ b/crates/nu-command/src/strings/str_/mod.rs @@ -14,16 +14,16 @@ mod substring; mod trim; pub use case::*; -pub use contains::SubCommand as StrContains; -pub use distance::SubCommand as StrDistance; -pub use ends_with::SubCommand as StrEndswith; -pub use expand::SubCommand as StrExpand; -pub use index_of::SubCommand as StrIndexOf; +pub use contains::StrContains; +pub use distance::StrDistance; +pub use ends_with::StrEndswith; +pub use expand::StrExpand; +pub use index_of::StrIndexOf; pub use join::*; -pub use length::SubCommand as StrLength; -pub use replace::SubCommand as StrReplace; -pub use reverse::SubCommand as StrReverse; -pub use starts_with::SubCommand as StrStartsWith; -pub use stats::SubCommand as StrStats; -pub use substring::SubCommand as StrSubstring; -pub use trim::Trim as StrTrim; +pub use length::StrLength; +pub use replace::StrReplace; +pub use reverse::StrReverse; +pub use starts_with::StrStartsWith; +pub use stats::StrStats; +pub use substring::StrSubstring; +pub use trim::StrTrim; diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index a893a88c62..50ba95cdd4 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -19,9 +19,9 @@ impl CmdArgument for Arguments { } #[derive(Clone)] -pub struct SubCommand; +pub struct StrReplace; -impl Command for SubCommand { +impl Command for StrReplace { fn name(&self) -> &str { "str replace" } @@ -304,7 +304,7 @@ fn action( #[cfg(test)] mod tests { use super::*; - use super::{action, Arguments, SubCommand}; + use super::{action, Arguments, StrReplace}; fn test_spanned_string(val: &str) -> Spanned { Spanned { @@ -317,7 +317,7 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrReplace {}) } #[test] diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index 310efed854..158c284200 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -2,9 +2,9 @@ use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrReverse; -impl Command for SubCommand { +impl Command for StrReverse { fn name(&self) -> &str { "str reverse" } @@ -117,6 +117,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrReverse {}) } } diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index fecf560519..9d708e23da 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -17,9 +17,9 @@ impl CmdArgument for Arguments { #[derive(Clone)] -pub struct SubCommand; +pub struct StrStartsWith; -impl Command for SubCommand { +impl Command for StrStartsWith { fn name(&self) -> &str { "str starts-with" } @@ -161,6 +161,6 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrStartsWith {}) } } diff --git a/crates/nu-command/src/strings/str_/stats.rs b/crates/nu-command/src/strings/str_/stats.rs index 6566b566c6..bd0bbfdd8f 100644 --- a/crates/nu-command/src/strings/str_/stats.rs +++ b/crates/nu-command/src/strings/str_/stats.rs @@ -9,9 +9,9 @@ use unicode_segmentation::UnicodeSegmentation; pub type Counted = BTreeMap; #[derive(Clone)] -pub struct SubCommand; +pub struct StrStats; -impl Command for SubCommand { +impl Command for StrStats { fn name(&self) -> &str { "str stats" } @@ -293,7 +293,7 @@ mod test { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrStats {}) } } diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index 57e4426f49..6fbcb05358 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -7,7 +7,7 @@ use nu_protocol::{engine::StateWorkingSet, IntRange}; use unicode_segmentation::UnicodeSegmentation; #[derive(Clone)] -pub struct SubCommand; +pub struct StrSubstring; struct Arguments { range: IntRange, @@ -21,7 +21,7 @@ impl CmdArgument for Arguments { } } -impl Command for SubCommand { +impl Command for StrSubstring { fn name(&self) -> &str { "str substring" } @@ -188,13 +188,13 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value { mod tests { use nu_protocol::IntRange; - use super::{action, Arguments, Span, SubCommand, Value}; + use super::{action, Arguments, Span, StrSubstring, Value}; #[test] fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrSubstring {}) } #[derive(Clone, Copy, Debug)] diff --git a/crates/nu-command/src/strings/str_/trim/mod.rs b/crates/nu-command/src/strings/str_/trim/mod.rs index 33d949ef5c..236f835d52 100644 --- a/crates/nu-command/src/strings/str_/trim/mod.rs +++ b/crates/nu-command/src/strings/str_/trim/mod.rs @@ -1,2 +1,2 @@ mod trim_; -pub use trim_::SubCommand as Trim; +pub use trim_::StrTrim; diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index 71e4359f78..014a9bb469 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -2,7 +2,7 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; #[derive(Clone)] -pub struct SubCommand; +pub struct StrTrim; struct Arguments { to_trim: Option, @@ -23,7 +23,7 @@ pub enum TrimSide { Both, } -impl Command for SubCommand { +impl Command for StrTrim { fn name(&self) -> &str { "str trim" } @@ -272,7 +272,7 @@ mod tests { fn test_examples() { use crate::test_examples; - test_examples(SubCommand {}) + test_examples(StrTrim {}) } fn make_record(cols: Vec<&str>, vals: Vec<&str>) -> Value { From 74f62305b289498bb9a182f2b1185d769215ddd6 Mon Sep 17 00:00:00 2001 From: zc he Date: Sat, 15 Mar 2025 22:17:59 +0800 Subject: [PATCH 21/59] fix(completion): more quoting for file_completion/directory_completion (#15299) # Description Found inconsistent behaviors of `directory_completion` and `file_completion`, https://github.com/nushell/nushell/issues/13951 https://github.com/nushell/reedline/pull/886 Also there're failing cases with such file names/dir names `foo(`, `foo{`, `foo[`. I think it doesn't harm to be more conservative at adding quotes, even if it might be unnecessary for paired names like `foo{}`. # User-Facing Changes # Tests + Formatting Adjusted # After Submitting --- .../src/completions/completion_common.rs | 38 +++++++++---------- crates/nu-cli/tests/completions/mod.rs | 24 ++++++++++++ .../partial_completions/partial-d(/.gitkeep | 0 .../quoted_completions/curly-bracket_{.txt | 0 .../quoted_completions/semicolon_;.txt | 0 .../quoted_completions/square-bracket_[.txt | 0 6 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 tests/fixtures/partial_completions/partial-d(/.gitkeep create mode 100644 tests/fixtures/quoted_completions/curly-bracket_{.txt create mode 100644 tests/fixtures/quoted_completions/semicolon_;.txt create mode 100644 tests/fixtures/quoted_completions/square-bracket_[.txt diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 31a4bdd75b..7d4cc670f8 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -276,7 +276,7 @@ pub fn complete_item( }); FileSuggestion { span, - path: escape_path(path, want_directory), + path: escape_path(path), style, is_dir, } @@ -285,30 +285,30 @@ pub fn complete_item( } // Fix files or folders with quotes or hashes -pub fn escape_path(path: String, dir: bool) -> String { +pub fn escape_path(path: String) -> String { // make glob pattern have the highest priority. - if nu_glob::is_glob(path.as_str()) { + if nu_glob::is_glob(path.as_str()) || path.contains('`') { + // expand home `~` for https://github.com/nushell/nushell/issues/13905 let pathbuf = nu_path::expand_tilde(path); let path = pathbuf.to_string_lossy(); - return if path.contains('\'') { - // decide to use double quote, also need to escape `"` in path - // or else users can't do anything with completed path either. - format!("\"{}\"", path.replace('"', r#"\""#)) + if path.contains('\'') { + // decide to use double quotes + // Path as Debug will do the escaping for `"`, `\` + format!("{:?}", path) } else { format!("'{path}'") - }; - } - - let filename_contaminated = !dir && path.contains(['\'', '"', ' ', '#', '(', ')']); - let dirname_contaminated = dir && path.contains(['\'', '"', ' ', '#']); - let maybe_flag = path.starts_with('-'); - let maybe_variable = path.starts_with('$'); - let maybe_number = path.parse::().is_ok(); - if filename_contaminated || dirname_contaminated || maybe_flag || maybe_variable || maybe_number - { - format!("`{path}`") + } } else { - path + let contaminated = + path.contains(['\'', '"', ' ', '#', '(', ')', '{', '}', '[', ']', '|', ';']); + let maybe_flag = path.starts_with('-'); + let maybe_variable = path.starts_with('$'); + let maybe_number = path.parse::().is_ok(); + if contaminated || maybe_flag || maybe_variable || maybe_number { + format!("`{path}`") + } else { + path + } } } diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index 5890aa21da..0326c9ba84 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -896,6 +896,7 @@ fn partial_completions() { folder(dir.join("partial-a")), folder(dir.join("partial-b")), folder(dir.join("partial-c")), + format!("`{}`", folder(dir.join("partial-d("))), ]; // Match the results @@ -938,6 +939,7 @@ fn partial_completions() { file(dir.join("partial-b").join("hello_b")), file(dir.join("partial-b").join("hi_b")), file(dir.join("partial-c").join("hello_c")), + format!("`{}`", file(dir.join("partial-d(").join(".gitkeep"))), ]; // Match the results @@ -985,6 +987,15 @@ fn partial_completions() { .join("final_partial") .join("somefile"), ), + format!( + "`{}`", + file( + dir.join("partial-d(") + .join("..") + .join("final_partial") + .join("somefile"), + ) + ), ]; // Match the results @@ -1065,6 +1076,16 @@ fn partial_completion_with_dot_expansions() { .join("final_partial") .join("somefile"), ), + format!( + "`{}`", + file( + dir.join("partial-d(") + .join("...") + .join("partial_completions") + .join("final_partial") + .join("somefile"), + ) + ), ]; // Match the results @@ -1389,6 +1410,9 @@ fn file_completion_quoted() { "`-inf`", "`4.2`", "\'[a] bc.txt\'", + "`curly-bracket_{.txt`", + "`semicolon_;.txt`", + "'square-bracket_[.txt'", "`te st.txt`", "`te#st.txt`", "`te'st.txt`", diff --git a/tests/fixtures/partial_completions/partial-d(/.gitkeep b/tests/fixtures/partial_completions/partial-d(/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/fixtures/quoted_completions/curly-bracket_{.txt b/tests/fixtures/quoted_completions/curly-bracket_{.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/fixtures/quoted_completions/semicolon_;.txt b/tests/fixtures/quoted_completions/semicolon_;.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/fixtures/quoted_completions/square-bracket_[.txt b/tests/fixtures/quoted_completions/square-bracket_[.txt new file mode 100644 index 0000000000..e69de29bb2 From 42aa2ff5ba702671e830a1d6ec468620c751e135 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sat, 15 Mar 2025 09:32:55 -0500 Subject: [PATCH 22/59] remove mimalloc allocator (#15317) # Description This PR removes the mimalloc allocator due to run-away memory leaks recently found. closes #15311 # User-Facing Changes # Tests + Formatting # After Submitting --- Cargo.lock | 21 ------------------- Cargo.toml | 3 --- crates/nu-cmd-lang/Cargo.toml | 1 - .../nu-cmd-lang/src/core_commands/version.rs | 6 +----- crates/nu_plugin_polars/Cargo.toml | 1 - crates/nu_plugin_polars/src/main.rs | 3 --- src/main.rs | 4 ---- 7 files changed, 1 insertion(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b875372064..f9244630e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2951,16 +2951,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" -[[package]] -name = "libmimalloc-sys" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libproc" version = "0.14.10" @@ -3256,15 +3246,6 @@ dependencies = [ "syn 2.0.90", ] -[[package]] -name = "mimalloc" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "mime" version = "0.3.17" @@ -3475,7 +3456,6 @@ dependencies = [ "fancy-regex", "log", "miette", - "mimalloc", "multipart-rs", "nix 0.29.0", "nu-cli", @@ -4132,7 +4112,6 @@ dependencies = [ "hashbrown 0.15.2", "indexmap", "log", - "mimalloc", "nu-cmd-lang", "nu-command", "nu-engine", diff --git a/Cargo.toml b/Cargo.toml index a237777e22..316c825b63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -220,7 +220,6 @@ ctrlc = { workspace = true } dirs = { workspace = true } log = { workspace = true } miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] } -mimalloc = { version = "0.1.42", default-features = false, optional = true } multipart-rs = { workspace = true } serde_json = { workspace = true } simplelog = "0.12" @@ -274,7 +273,6 @@ default = [ "plugin", "trash-support", "sqlite", - "mimalloc", ] stable = ["default"] # NOTE: individual features are also passed to `nu-cmd-lang` that uses them to generate the feature matrix in the `version` command @@ -283,7 +281,6 @@ stable = ["default"] # otherwise the system version will be used. Not enabled by default because it takes a while to build static-link-openssl = ["dep:openssl", "nu-cmd-lang/static-link-openssl"] -mimalloc = ["nu-cmd-lang/mimalloc", "dep:mimalloc"] # Optional system clipboard support in `reedline`, this behavior has problematic compatibility with some systems. # Missing X server/ Wayland can cause issues system-clipboard = [ diff --git a/crates/nu-cmd-lang/Cargo.toml b/crates/nu-cmd-lang/Cargo.toml index 2cc86bd782..e505a1c853 100644 --- a/crates/nu-cmd-lang/Cargo.toml +++ b/crates/nu-cmd-lang/Cargo.toml @@ -42,7 +42,6 @@ plugin = [ "os", ] -mimalloc = [] trash-support = [] sqlite = [] static-link-openssl = [] diff --git a/crates/nu-cmd-lang/src/core_commands/version.rs b/crates/nu-cmd-lang/src/core_commands/version.rs index 9ebc43dee2..5ea4cfb4be 100644 --- a/crates/nu-cmd-lang/src/core_commands/version.rs +++ b/crates/nu-cmd-lang/src/core_commands/version.rs @@ -161,11 +161,7 @@ fn push_version_numbers(record: &mut Record, head: Span) { } fn global_allocator() -> &'static str { - if cfg!(feature = "mimalloc") { - "mimalloc" - } else { - "standard" - } + "standard" } fn features_enabled() -> Vec { diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index 1b91d0d760..d88c1c161b 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -27,7 +27,6 @@ chrono = { workspace = true, features = ["std", "unstable-locales"], default-fea chrono-tz = "0.10" fancy-regex = { workspace = true } indexmap = { version = "2.7" } -mimalloc = { version = "0.1.42" } num = {version = "0.4"} serde = { version = "1.0", features = ["derive"] } sqlparser = { version = "0.53"} diff --git a/crates/nu_plugin_polars/src/main.rs b/crates/nu_plugin_polars/src/main.rs index 3f880a10e4..850d5abf38 100644 --- a/crates/nu_plugin_polars/src/main.rs +++ b/crates/nu_plugin_polars/src/main.rs @@ -1,9 +1,6 @@ use nu_plugin::{serve_plugin, MsgPackSerializer}; use nu_plugin_polars::PolarsPlugin; -#[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; - fn main() { env_logger::init(); diff --git a/src/main.rs b/src/main.rs index 1c9a49f3b4..f514eb47d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,10 +9,6 @@ mod signals; mod terminal; mod test_bins; -#[cfg(feature = "mimalloc")] -#[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; - use crate::{ command::parse_commandline_args, config_files::set_config_path, From 1dd861b10f8651877ee6fa708c9718dc68ff2f8e Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Sun, 16 Mar 2025 16:33:36 +0100 Subject: [PATCH 23/59] Close find handle in `ls` windows unsafe code (#15314) While inspecting the Windows specific code of `ls` for #15311 I stumbled upon an unrelated issue in the alternate metadata gathering on Windows (added by #5703). The handle created by performing `FindFirstFileW` was never closed, leading to a potential leak. Fixed by running `FindClose` as soon as the operation succeeds. https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilew#remarks --- crates/nu-command/src/filesystem/ls.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/nu-command/src/filesystem/ls.rs b/crates/nu-command/src/filesystem/ls.rs index e80d49f846..cda0fc0826 100644 --- a/crates/nu-command/src/filesystem/ls.rs +++ b/crates/nu-command/src/filesystem/ls.rs @@ -802,7 +802,7 @@ mod windows_helper { use std::os::windows::prelude::OsStrExt; use windows::Win32::Foundation::FILETIME; use windows::Win32::Storage::FileSystem::{ - FindFirstFileW, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_READONLY, + FindClose, FindFirstFileW, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_REPARSE_POINT, WIN32_FIND_DATAW, }; use windows::Win32::System::SystemServices::{ @@ -925,7 +925,14 @@ mod windows_helper { windows::core::PCWSTR(filename_wide.as_ptr()), &mut find_data, ) { - Ok(_) => Ok(find_data), + Ok(handle) => { + // Don't forget to close the Find handle + // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilew#remarks + // Assumption: WIN32_FIND_DATAW is a pure data struct, so we can let our + // find_data outlive the handle. + let _ = FindClose(handle); + Ok(find_data) + } Err(e) => Err(ShellError::Io(IoError::new_with_additional_context( std::io::ErrorKind::Other, span, From 00e5e6d719e0cf2c76c2e14115fbed7290228251 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Mon, 17 Mar 2025 02:44:41 +0800 Subject: [PATCH 24/59] Update toolkit.nu add nu_plugin_polars plugin for build and install (#15324) # Description Update `toolkit.nu` add `nu_plugin_polars` plugin for build and install # User-Facing Changes `toolkit install --all` and `toolkit build --all` will have `nu_plugin_polars` included --- toolkit.nu | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/toolkit.nu b/toolkit.nu index c185f2ea7f..ee4a63035d 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -355,6 +355,7 @@ export def build [ nu_plugin_inc, nu_plugin_gstat, nu_plugin_query, + nu_plugin_polars, nu_plugin_example, nu_plugin_custom_values, nu_plugin_formats, @@ -393,6 +394,7 @@ export def install [ nu_plugin_inc, nu_plugin_gstat, nu_plugin_query, + nu_plugin_polars, nu_plugin_example, nu_plugin_custom_values, nu_plugin_formats, @@ -628,9 +630,9 @@ export def "build wasm" [] { print $'(char nl)Building ($crate) for wasm' print '----------------------------' ( - ^cargo build - -p $crate - --target wasm32-unknown-unknown + ^cargo build + -p $crate + --target wasm32-unknown-unknown --no-default-features ) } @@ -646,9 +648,9 @@ export def "clippy wasm" [] { print $'(char nl)Checking ($crate) for wasm' print '----------------------------' ( - ^cargo clippy - -p $crate - --target wasm32-unknown-unknown + ^cargo clippy + -p $crate + --target wasm32-unknown-unknown --no-default-features -- -D warnings From 83de8560ee7cc5f82ba11187e471991d23d74926 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Sun, 16 Mar 2025 15:15:02 -0400 Subject: [PATCH 25/59] Unify closure serializing logic for `to nuon`, `to msgpack`, and `to json` (#15285) # Description Before this PR, `to msgpack`/`to msgpackz` and `to json` serialize closures as `nil`/`null` respectively, when the `--serialize` option isn't passed. This PR makes it an error to serialize closures to msgpack or JSON without the `--serialize` flag, which is the behavior of `to nuon`. This PR also adds the `--serialize` flag to `to msgpack`. This PR also changes `to nuon` and `to json` to return an error if they cannot find the block contents of a closure, rather than serializing an empty string or an error string, respectively. This behavior is replicated for `to msgpack`. It also changes `to nuon`'s error message for serializing closures without `--serialize` to be the same as the new errors for `to json` and `to msgpack`. # User-Facing Changes * Add `--serialize` flag to `to msgpack`, similar to the `--serialize` flag for `to nuon` and `to json`. * Serializing closures to JSON or msgpack without `--serialize` Partially fixes #11738 --- crates/nu-command/src/formats/to/json.rs | 51 +++++++-------- crates/nu-command/src/formats/to/msgpack.rs | 65 +++++++++++++++---- crates/nu-command/src/formats/to/msgpackz.rs | 15 ++++- crates/nu-command/src/formats/to/nuon.rs | 13 +--- crates/nu-command/src/network/http/client.rs | 2 +- .../nu-protocol/src/engine/capture_block.rs | 9 --- crates/nu-protocol/src/engine/closure.rs | 35 ++++++++++ crates/nu-protocol/src/engine/mod.rs | 4 +- crates/nuon/src/to.rs | 11 +--- 9 files changed, 136 insertions(+), 69 deletions(-) delete mode 100644 crates/nu-protocol/src/engine/capture_block.rs create mode 100644 crates/nu-protocol/src/engine/closure.rs diff --git a/crates/nu-command/src/formats/to/json.rs b/crates/nu-command/src/formats/to/json.rs index 7eb749977f..55d5d80b7a 100644 --- a/crates/nu-command/src/formats/to/json.rs +++ b/crates/nu-command/src/formats/to/json.rs @@ -57,7 +57,7 @@ impl Command for ToJson { // allow ranges to expand and turn into array let input = input.try_expand_range()?; let value = input.into_value(span)?; - let json_value = value_to_json_value(engine_state, &value, serialize_types)?; + let json_value = value_to_json_value(engine_state, &value, span, serialize_types)?; let json_result = if raw { nu_json::to_string_raw(&json_value) @@ -78,16 +78,12 @@ impl Command for ToJson { }; Ok(PipelineData::Value(res, Some(metadata))) } - _ => Ok(Value::error( - ShellError::CantConvert { - to_type: "JSON".into(), - from_type: value.get_type().to_string(), - span, - help: None, - }, + _ => Err(ShellError::CantConvert { + to_type: "JSON".into(), + from_type: value.get_type().to_string(), span, - ) - .into_pipeline_data()), + help: None, + }), } } @@ -118,6 +114,7 @@ impl Command for ToJson { pub fn value_to_json_value( engine_state: &EngineState, v: &Value, + call_span: Span, serialize_types: bool, ) -> Result { let span = v.span(); @@ -142,24 +139,20 @@ pub fn value_to_json_value( ), Value::List { vals, .. } => { - nu_json::Value::Array(json_list(engine_state, vals, serialize_types)?) + nu_json::Value::Array(json_list(engine_state, vals, call_span, serialize_types)?) } Value::Error { error, .. } => return Err(*error.clone()), Value::Closure { val, .. } => { if serialize_types { - let block = engine_state.get_block(val.block_id); - if let Some(span) = block.span { - let contents_bytes = engine_state.get_span_contents(span); - let contents_string = String::from_utf8_lossy(contents_bytes); - nu_json::Value::String(contents_string.to_string()) - } else { - nu_json::Value::String(format!( - "unable to retrieve block contents for json block_id {}", - val.block_id.get() - )) - } + let closure_string = val.coerce_into_string(engine_state, span)?; + nu_json::Value::String(closure_string.to_string()) } else { - nu_json::Value::Null + return Err(ShellError::UnsupportedInput { + msg: "closures are currently not deserializable (use --serialize to serialize as a string)".into(), + input: "value originates from here".into(), + msg_span: call_span, + input_span: span, + }); } } Value::Range { .. } => nu_json::Value::Null, @@ -171,14 +164,14 @@ pub fn value_to_json_value( for (k, v) in &**val { m.insert( k.clone(), - value_to_json_value(engine_state, v, serialize_types)?, + value_to_json_value(engine_state, v, call_span, serialize_types)?, ); } nu_json::Value::Object(m) } Value::Custom { val, .. } => { let collected = val.to_base_value(span)?; - value_to_json_value(engine_state, &collected, serialize_types)? + value_to_json_value(engine_state, &collected, call_span, serialize_types)? } }) } @@ -186,12 +179,18 @@ pub fn value_to_json_value( fn json_list( engine_state: &EngineState, input: &[Value], + call_span: Span, serialize_types: bool, ) -> Result, ShellError> { let mut out = vec![]; for value in input { - out.push(value_to_json_value(engine_state, value, serialize_types)?); + out.push(value_to_json_value( + engine_state, + value, + call_span, + serialize_types, + )?); } Ok(out) diff --git a/crates/nu-command/src/formats/to/msgpack.rs b/crates/nu-command/src/formats/to/msgpack.rs index ae1d11e542..3040d26c2a 100644 --- a/crates/nu-command/src/formats/to/msgpack.rs +++ b/crates/nu-command/src/formats/to/msgpack.rs @@ -22,6 +22,11 @@ impl Command for ToMsgpack { fn signature(&self) -> Signature { Signature::build(self.name()) .input_output_type(Type::Any, Type::Binary) + .switch( + "serialize", + "serialize nushell types that cannot be deserialized", + Some('s'), + ) .category(Category::Formats) } @@ -69,8 +74,8 @@ MessagePack: https://msgpack.org/ fn run( &self, - _engine_state: &EngineState, - _stack: &mut Stack, + engine_state: &EngineState, + stack: &mut Stack, call: &Call, input: PipelineData, ) -> Result { @@ -83,7 +88,16 @@ MessagePack: https://msgpack.org/ let value = input.into_value(value_span)?; let mut out = vec![]; - write_value(&mut out, &value, 0)?; + let serialize_types = call.has_flag(engine_state, stack, "serialize")?; + + write_value( + &mut out, + &value, + 0, + engine_state, + call.head, + serialize_types, + )?; Ok(Value::binary(out, call.head).into_pipeline_data_with_metadata(Some(metadata))) } @@ -148,6 +162,9 @@ pub(crate) fn write_value( out: &mut impl io::Write, value: &Value, depth: usize, + engine_state: &EngineState, + call_span: Span, + serialize_types: bool, ) -> Result<(), WriteError> { use mp::ValueWriteError::InvalidMarkerWrite; let span = value.span(); @@ -196,6 +213,9 @@ pub(crate) fn write_value( out, &Value::list(val.into_range_iter(span, Signals::empty()).collect(), span), depth, + engine_state, + call_span, + serialize_types, )?; } Value::String { val, .. } => { @@ -208,13 +228,20 @@ pub(crate) fn write_value( mp::write_map_len(out, convert(val.len(), span)?).err_span(span)?; for (k, v) in val.iter() { mp::write_str(out, k).err_span(span)?; - write_value(out, v, depth + 1)?; + write_value(out, v, depth + 1, engine_state, call_span, serialize_types)?; } } Value::List { vals, .. } => { mp::write_array_len(out, convert(vals.len(), span)?).err_span(span)?; for val in vals { - write_value(out, val, depth + 1)?; + write_value( + out, + val, + depth + 1, + engine_state, + call_span, + serialize_types, + )?; } } Value::Nothing { .. } => { @@ -222,11 +249,20 @@ pub(crate) fn write_value( .map_err(InvalidMarkerWrite) .err_span(span)?; } - Value::Closure { .. } => { - // Closures can't be converted - mp::write_nil(out) - .map_err(InvalidMarkerWrite) - .err_span(span)?; + Value::Closure { val, .. } => { + if serialize_types { + let closure_string = val + .coerce_into_string(engine_state, span) + .map_err(|err| WriteError::Shell(Box::new(err)))?; + mp::write_str(out, &closure_string).err_span(span)?; + } else { + return Err(WriteError::Shell(Box::new(ShellError::UnsupportedInput { + msg: "closures are currently not deserializable (use --serialize to serialize as a string)".into(), + input: "value originates from here".into(), + msg_span: call_span, + input_span: span, + }))); + } } Value::Error { error, .. } => { return Err(WriteError::Shell(error.clone())); @@ -249,7 +285,14 @@ pub(crate) fn write_value( mp::write_bin(out, val).err_span(span)?; } Value::Custom { val, .. } => { - write_value(out, &val.to_base_value(span)?, depth)?; + write_value( + out, + &val.to_base_value(span)?, + depth, + engine_state, + call_span, + serialize_types, + )?; } } Ok(()) diff --git a/crates/nu-command/src/formats/to/msgpackz.rs b/crates/nu-command/src/formats/to/msgpackz.rs index c6d667280f..c76aa17d60 100644 --- a/crates/nu-command/src/formats/to/msgpackz.rs +++ b/crates/nu-command/src/formats/to/msgpackz.rs @@ -32,6 +32,11 @@ impl Command for ToMsgpackz { "Window size for brotli compression (default 20)", Some('w'), ) + .switch( + "serialize", + "serialize nushell types that cannot be deserialized", + Some('s'), + ) .category(Category::Formats) } @@ -69,6 +74,7 @@ impl Command for ToMsgpackz { .get_flag(engine_state, stack, "window-size")? .map(to_u32) .transpose()?; + let serialize_types = call.has_flag(engine_state, stack, "serialize")?; let value_span = input.span().unwrap_or(call.head); let value = input.into_value(value_span)?; @@ -80,7 +86,14 @@ impl Command for ToMsgpackz { window_size.map(|w| w.item).unwrap_or(DEFAULT_WINDOW_SIZE), ); - write_value(&mut out, &value, 0)?; + write_value( + &mut out, + &value, + 0, + engine_state, + call.head, + serialize_types, + )?; out.flush() .map_err(|err| IoError::new(err.kind(), call.head, None))?; drop(out); diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index 4f7cde1d0b..5e5e505bd8 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -69,16 +69,9 @@ impl Command for ToNuon { match nuon::to_nuon(engine_state, &value, style, Some(span), serialize_types) { Ok(serde_nuon_string) => Ok(Value::string(serde_nuon_string, span) .into_pipeline_data_with_metadata(Some(metadata))), - _ => Ok(Value::error( - ShellError::CantConvert { - to_type: "NUON".into(), - from_type: value.get_type().to_string(), - span, - help: None, - }, - span, - ) - .into_pipeline_data_with_metadata(Some(metadata))), + Err(error) => { + Ok(Value::error(error, span).into_pipeline_data_with_metadata(Some(metadata))) + } } } diff --git a/crates/nu-command/src/network/http/client.rs b/crates/nu-command/src/network/http/client.rs index 28a8bc8207..271c521715 100644 --- a/crates/nu-command/src/network/http/client.rs +++ b/crates/nu-command/src/network/http/client.rs @@ -276,7 +276,7 @@ fn send_json_request( ) -> Result { match body { Value::Int { .. } | Value::Float { .. } | Value::List { .. } | Value::Record { .. } => { - let data = value_to_json_value(engine_state, &body, serialize_types)?; + let data = value_to_json_value(engine_state, &body, span, serialize_types)?; send_cancellable_request(request_url, Box::new(|| req.send_json(data)), span, signals) } // If the body type is string, assume it is string json content. diff --git a/crates/nu-protocol/src/engine/capture_block.rs b/crates/nu-protocol/src/engine/capture_block.rs deleted file mode 100644 index 6054487d92..0000000000 --- a/crates/nu-protocol/src/engine/capture_block.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::{BlockId, Value, VarId}; - -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct Closure { - pub block_id: BlockId, - pub captures: Vec<(VarId, Value)>, -} diff --git a/crates/nu-protocol/src/engine/closure.rs b/crates/nu-protocol/src/engine/closure.rs new file mode 100644 index 0000000000..a10867fc5b --- /dev/null +++ b/crates/nu-protocol/src/engine/closure.rs @@ -0,0 +1,35 @@ +use std::borrow::Cow; + +use crate::{engine::EngineState, BlockId, ShellError, Span, Value, VarId}; + +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Closure { + pub block_id: BlockId, + pub captures: Vec<(VarId, Value)>, +} + +impl Closure { + pub fn coerce_into_string<'a>( + &self, + engine_state: &'a EngineState, + span: Span, + ) -> Result, ShellError> { + let block = engine_state.get_block(self.block_id); + if let Some(span) = block.span { + let contents_bytes = engine_state.get_span_contents(span); + Ok(String::from_utf8_lossy(contents_bytes)) + } else { + Err(ShellError::CantConvert { + to_type: "string".into(), + from_type: "closure".into(), + span, + help: Some(format!( + "unable to retrieve block contents for closure with id {}", + self.block_id.get() + )), + }) + } + } +} diff --git a/crates/nu-protocol/src/engine/mod.rs b/crates/nu-protocol/src/engine/mod.rs index 3e6ed90f00..1bd315cf04 100644 --- a/crates/nu-protocol/src/engine/mod.rs +++ b/crates/nu-protocol/src/engine/mod.rs @@ -3,7 +3,7 @@ mod argument; mod cached_file; mod call; mod call_info; -mod capture_block; +mod closure; mod command; mod description; mod engine_state; @@ -23,7 +23,7 @@ pub use cached_file::CachedFile; pub use argument::*; pub use call::*; pub use call_info::*; -pub use capture_block::*; +pub use closure::*; pub use command::*; pub use engine_state::*; pub use error_handler::*; diff --git a/crates/nuon/src/to.rs b/crates/nuon/src/to.rs index 332dcaf98e..e7ed06c461 100644 --- a/crates/nuon/src/to.rs +++ b/crates/nuon/src/to.rs @@ -99,17 +99,10 @@ fn value_to_string( } Value::Closure { val, .. } => { if serialize_types { - let block = engine_state.get_block(val.block_id); - if let Some(span) = block.span { - let contents_bytes = engine_state.get_span_contents(span); - let contents_string = String::from_utf8_lossy(contents_bytes); - Ok(contents_string.to_string()) - } else { - Ok(String::new()) - } + Ok(val.coerce_into_string(engine_state, span)?.to_string()) } else { Err(ShellError::UnsupportedInput { - msg: "closures are currently not nuon-compatible".into(), + msg: "closures are currently not deserializable (use --serialize to serialize as a string)".into(), input: "value originates from here".into(), msg_span: span, input_span: v.span(), From c949d2e89316e005c02ed0d10adfc7828179273b Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Sun, 16 Mar 2025 13:11:05 -0700 Subject: [PATCH 26/59] `into string` should not modify strings (#15320) # Description `into string` should not modify input strings (even with the `--group-digits` flag). It's a conversion command, not a formatting command. # User-Facing Changes - For strings, the same behavior from 0.102.0 is preserved. - Errors are no longer turned into strings, but rather they are returned as is. # After Submitting Create a `format int` and/or `format float` command and so that the `--group-digits` flag can be transferred to one of those commands. --- .../nu-command/src/conversions/into/string.rs | 18 ++++-------------- .../nu-protocol/src/errors/shell_error/mod.rs | 4 ---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/crates/nu-command/src/conversions/into/string.rs b/crates/nu-command/src/conversions/into/string.rs index cc48754361..2e7f096520 100644 --- a/crates/nu-command/src/conversions/into/string.rs +++ b/crates/nu-command/src/conversions/into/string.rs @@ -1,6 +1,6 @@ use nu_cmd_base::input_handler::{operate, CmdArgument}; use nu_engine::command_prelude::*; -use nu_protocol::{shell_error::into_code, Config}; +use nu_protocol::Config; use nu_utils::get_system_locale; use num_format::ToFormattedString; use std::sync::Arc; @@ -215,17 +215,8 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value { } Value::Bool { val, .. } => Value::string(val.to_string(), span), Value::Date { val, .. } => Value::string(val.format("%c").to_string(), span), - Value::String { val, .. } => { - if group_digits { - let number = val.parse::().unwrap_or_default(); - let decimal_value = digits.unwrap_or(0) as usize; - Value::string(format_int(number, group_digits, decimal_value), span) - } else { - Value::string(val.to_string(), span) - } - } - Value::Glob { val, .. } => Value::string(val.to_string(), span), - + Value::String { val, .. } => Value::string(val, span), + Value::Glob { val, .. } => Value::string(val, span), Value::Filesize { val, .. } => { if group_digits { let decimal_value = digits.unwrap_or(0) as usize; @@ -235,8 +226,6 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value { } } Value::Duration { val: _, .. } => Value::string(input.to_expanded_string("", config), span), - - Value::Error { error, .. } => Value::string(into_code(error).unwrap_or_default(), span), Value::Nothing { .. } => Value::string("".to_string(), span), Value::Record { .. } => Value::error( // Watch out for CantConvert's argument order @@ -272,6 +261,7 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value { }) .unwrap_or_else(|err| Value::error(err, span)) } + Value::Error { .. } => input.clone(), x => Value::error( ShellError::CantConvert { to_type: String::from("string"), diff --git a/crates/nu-protocol/src/errors/shell_error/mod.rs b/crates/nu-protocol/src/errors/shell_error/mod.rs index da4ba3dc1a..627c3679b3 100644 --- a/crates/nu-protocol/src/errors/shell_error/mod.rs +++ b/crates/nu-protocol/src/errors/shell_error/mod.rs @@ -1474,10 +1474,6 @@ impl<'de> Deserialize<'de> for ShellError { } } -pub fn into_code(err: &ShellError) -> Option { - err.code().map(|code| code.to_string()) -} - #[test] fn shell_error_serialize_roundtrip() { // Ensure that we can serialize and deserialize `ShellError`, and check that it basically would From 2c35e07c2dfb7925ff95af2f56dd9ced13b8e7fa Mon Sep 17 00:00:00 2001 From: zc he Date: Mon, 17 Mar 2025 19:54:48 +0800 Subject: [PATCH 27/59] fix(lsp): ansi strip on hover text (#15331) Fixes messed ansi escapes in hover text (manpage): image # Description That bug is introduced in #15115. Also refactored the hover related code to a separate file, just like other features. # User-Facing Changes # Tests + Formatting # After Submitting --- Cargo.lock | 1 + crates/nu-lsp/Cargo.toml | 1 + crates/nu-lsp/src/hover.rs | 411 +++++++++++++++++++++++++++++++++++++ crates/nu-lsp/src/lib.rs | 407 +----------------------------------- 4 files changed, 421 insertions(+), 399 deletions(-) create mode 100644 crates/nu-lsp/src/hover.rs diff --git a/Cargo.lock b/Cargo.lock index f9244630e4..e07c3cfa99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3808,6 +3808,7 @@ dependencies = [ "nu-parser", "nu-protocol", "nu-test-support", + "nu-utils", "nucleo-matcher", "serde", "serde_json", diff --git a/crates/nu-lsp/Cargo.toml b/crates/nu-lsp/Cargo.toml index d169ed15e7..1ec37ee844 100644 --- a/crates/nu-lsp/Cargo.toml +++ b/crates/nu-lsp/Cargo.toml @@ -12,6 +12,7 @@ nu-cli = { path = "../nu-cli", version = "0.102.1" } nu-glob = { path = "../nu-glob", version = "0.102.1" } nu-parser = { path = "../nu-parser", version = "0.102.1" } nu-protocol = { path = "../nu-protocol", version = "0.102.1" } +nu-utils = { path = "../nu-utils", version = "0.102.1" } crossbeam-channel = { workspace = true } lsp-server = { workspace = true } diff --git a/crates/nu-lsp/src/hover.rs b/crates/nu-lsp/src/hover.rs new file mode 100644 index 0000000000..8072e1b68d --- /dev/null +++ b/crates/nu-lsp/src/hover.rs @@ -0,0 +1,411 @@ +use lsp_types::{Hover, HoverContents, HoverParams, MarkupContent, MarkupKind}; +use nu_protocol::engine::Command; + +use crate::{Id, LanguageServer}; + +impl LanguageServer { + pub(crate) fn get_decl_description(decl: &dyn Command, skip_description: bool) -> String { + let mut description = String::new(); + + if !skip_description { + // First description + description.push_str(&format!("{}\n", decl.description().replace('\r', ""))); + + // Additional description + if !decl.extra_description().is_empty() { + description.push_str(&format!("\n{}\n", decl.extra_description())); + } + } + // Usage + description.push_str("---\n### Usage \n```nu\n"); + let signature = decl.signature(); + description.push_str(&Self::get_signature_label(&signature)); + description.push_str("\n```\n"); + + // Flags + if !signature.named.is_empty() { + description.push_str("\n### Flags\n\n"); + let mut first = true; + for named in &signature.named { + if first { + first = false; + } else { + description.push('\n'); + } + description.push_str(" "); + if let Some(short_flag) = &named.short { + description.push_str(&format!("`-{short_flag}`")); + } + if !named.long.is_empty() { + if named.short.is_some() { + description.push_str(", "); + } + description.push_str(&format!("`--{}`", named.long)); + } + if let Some(arg) = &named.arg { + description.push_str(&format!(" `<{}>`", arg.to_type())); + } + if !named.desc.is_empty() { + description.push_str(&format!(" - {}", named.desc)); + } + description.push('\n'); + } + description.push('\n'); + } + + // Parameters + if !signature.required_positional.is_empty() + || !signature.optional_positional.is_empty() + || signature.rest_positional.is_some() + { + description.push_str("\n### Parameters\n\n"); + let mut first = true; + for required_arg in &signature.required_positional { + if first { + first = false; + } else { + description.push('\n'); + } + description.push_str(&format!( + " `{}: {}`", + required_arg.name, + required_arg.shape.to_type() + )); + if !required_arg.desc.is_empty() { + description.push_str(&format!(" - {}", required_arg.desc)); + } + description.push('\n'); + } + for optional_arg in &signature.optional_positional { + if first { + first = false; + } else { + description.push('\n'); + } + description.push_str(&format!( + " `{}: {}`", + optional_arg.name, + optional_arg.shape.to_type() + )); + if !optional_arg.desc.is_empty() { + description.push_str(&format!(" - {}", optional_arg.desc)); + } + description.push('\n'); + } + if let Some(arg) = &signature.rest_positional { + if !first { + description.push('\n'); + } + description.push_str(&format!(" `...{}: {}`", arg.name, arg.shape.to_type())); + if !arg.desc.is_empty() { + description.push_str(&format!(" - {}", arg.desc)); + } + description.push('\n'); + } + description.push('\n'); + } + + // Input/output types + if !signature.input_output_types.is_empty() { + description.push_str("\n### Input/output types\n"); + description.push_str("\n```nu\n"); + for input_output in &signature.input_output_types { + description.push_str(&format!(" {} | {}\n", input_output.0, input_output.1)); + } + description.push_str("\n```\n"); + } + + // Examples + if !decl.examples().is_empty() { + description.push_str("### Example(s)\n"); + for example in decl.examples() { + description.push_str(&format!( + " {}\n```nu\n {}\n```\n", + example.description, example.example + )); + } + } + description + } + + pub(crate) fn hover(&mut self, params: &HoverParams) -> Option { + let mut engine_state = self.new_engine_state(); + + let path_uri = params + .text_document_position_params + .text_document + .uri + .to_owned(); + let (working_set, id, _, _) = self + .parse_and_find( + &mut engine_state, + &path_uri, + params.text_document_position_params.position, + ) + .ok()?; + + let markdown_hover = |content: String| { + Some(Hover { + contents: HoverContents::Markup(MarkupContent { + kind: MarkupKind::Markdown, + value: content, + }), + // TODO + range: None, + }) + }; + + match id { + Id::Variable(var_id) => { + let var = working_set.get_variable(var_id); + let value = var + .const_val + .clone() + .and_then(|v| v.coerce_into_string().ok()) + .unwrap_or(String::from(if var.mutable { + "mutable" + } else { + "immutable" + })); + let contents = format!("```\n{}\n``` \n---\n{}", var.ty, value); + markdown_hover(contents) + } + Id::CellPath(var_id, cell_path) => { + let var = working_set.get_variable(var_id); + markdown_hover( + var.const_val + .clone() + .and_then(|val| val.follow_cell_path(&cell_path, false).ok()) + .map(|val| { + let ty = val.get_type().clone(); + let value_string = val + .coerce_into_string() + .ok() + .map(|s| format!("\n---\n{}", s)) + .unwrap_or_default(); + format!("```\n{}\n```{}", ty, value_string) + }) + .unwrap_or("`unknown`".into()), + ) + } + Id::Declaration(decl_id) => markdown_hover(Self::get_decl_description( + working_set.get_decl(decl_id), + false, + )), + Id::Module(module_id) => { + let description = working_set + .get_module_comments(module_id)? + .iter() + .map(|sp| String::from_utf8_lossy(working_set.get_span_contents(*sp)).into()) + .collect::>() + .join("\n"); + markdown_hover(description) + } + Id::Value(t) => markdown_hover(format!("`{}`", t)), + Id::External(cmd) => { + let command_output = if cfg!(windows) { + std::process::Command::new("powershell.exe") + .args(["-NoProfile", "-Command", "help", &cmd]) + .output() + } else { + std::process::Command::new("man").arg(&cmd).output() + }; + let manpage_str = match command_output { + Ok(output) => nu_utils::strip_ansi_likely( + String::from_utf8_lossy(&output.stdout).as_ref(), + ) + .to_string(), + Err(_) => format!("No command help found for {}", &cmd), + }; + markdown_hover(manpage_str) + } + } + } +} + +#[cfg(test)] +mod hover_tests { + use crate::{ + path_to_uri, + tests::{ + initialize_language_server, open_unchecked, result_from_message, send_hover_request, + }, + }; + use assert_json_diff::assert_json_eq; + use nu_test_support::fs::fixtures; + + #[test] + fn hover_on_variable() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("var.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 2, 0); + + assert_json_eq!( + result_from_message(resp), + serde_json::json!({ "contents": { "kind": "markdown", "value": "```\ntable\n``` \n---\nimmutable" } }) + ); + } + + #[test] + fn hover_on_cell_path() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("cell_path.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + + let resp = send_hover_request(&client_connection, script.clone(), 4, 3); + let result = result_from_message(resp); + assert_json_eq!( + result.pointer("/contents/value").unwrap(), + serde_json::json!("```\nlist\n```") + ); + + let resp = send_hover_request(&client_connection, script.clone(), 4, 7); + let result = result_from_message(resp); + assert_json_eq!( + result.pointer("/contents/value").unwrap(), + serde_json::json!("```\nrecord\n```") + ); + + let resp = send_hover_request(&client_connection, script.clone(), 4, 11); + let result = result_from_message(resp); + assert_json_eq!( + result.pointer("/contents/value").unwrap(), + serde_json::json!("```\nint\n```\n---\n2") + ); + } + + #[test] + fn hover_on_custom_command() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("command.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 3, 0); + + assert_json_eq!( + result_from_message(resp), + serde_json::json!({ + "contents": { + "kind": "markdown", + "value": "Renders some greeting message\n---\n### Usage \n```nu\n hello {flags}\n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n" + } + }) + ); + } + + #[test] + fn hover_on_custom_in_custom() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("command.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 9, 7); + + assert_json_eq!( + result_from_message(resp), + serde_json::json!({ + "contents": { + "kind": "markdown", + "value": "\n---\n### Usage \n```nu\n bar {flags}\n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n" + } + }) + ); + } + + #[test] + fn hover_on_external_command() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("command.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 6, 2); + + let hover_text = result_from_message(resp) + .pointer("/contents/value") + .unwrap() + .as_str() + .unwrap() + .to_string(); + + #[cfg(not(windows))] + assert!(hover_text.contains("SLEEP")); + #[cfg(windows)] + assert!(hover_text.contains("Start-Sleep")); + } + + #[test] + fn hover_on_str_join() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("hover"); + script.push("command.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 5, 8); + + assert_json_eq!( + result_from_message(resp), + serde_json::json!({ + "contents": { + "kind": "markdown", + "value": "Concatenate multiple strings into a single string, with an optional separator between each.\n---\n### Usage \n```nu\n str join {flags} \n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n\n### Parameters\n\n `separator: string` - Optional separator to use when creating string.\n\n\n### Input/output types\n\n```nu\n list | string\n string | string\n\n```\n### Example(s)\n Create a string from input\n```nu\n ['nu', 'shell'] | str join\n```\n Create a string from input with a separator\n```nu\n ['nu', 'shell'] | str join '-'\n```\n" + } + }) + ); + } + + #[test] + fn hover_on_module() { + let (client_connection, _recv) = initialize_language_server(None, None); + + let mut script = fixtures(); + script.push("lsp"); + script.push("goto"); + script.push("module.nu"); + let script = path_to_uri(&script); + + open_unchecked(&client_connection, script.clone()); + let resp = send_hover_request(&client_connection, script.clone(), 3, 12); + let result = result_from_message(resp); + + assert_eq!( + result + .pointer("/contents/value") + .unwrap() + .to_string() + .replace("\\r", ""), + "\"# module doc\"" + ); + } +} diff --git a/crates/nu-lsp/src/lib.rs b/crates/nu-lsp/src/lib.rs index a61341c1e9..bcce8dcf89 100644 --- a/crates/nu-lsp/src/lib.rs +++ b/crates/nu-lsp/src/lib.rs @@ -3,16 +3,16 @@ use lsp_server::{Connection, IoThreads, Message, Response, ResponseError}; use lsp_textdocument::{FullTextDocument, TextDocuments}; use lsp_types::{ request::{self, Request}, - Hover, HoverContents, HoverParams, InlayHint, MarkupContent, MarkupKind, OneOf, Position, - Range, ReferencesOptions, RenameOptions, SemanticToken, SemanticTokenType, - SemanticTokensLegend, SemanticTokensOptions, SemanticTokensServerCapabilities, - ServerCapabilities, SignatureHelpOptions, TextDocumentSyncKind, Uri, WorkDoneProgressOptions, - WorkspaceFolder, WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities, + InlayHint, OneOf, Position, Range, ReferencesOptions, RenameOptions, SemanticToken, + SemanticTokenType, SemanticTokensLegend, SemanticTokensOptions, + SemanticTokensServerCapabilities, ServerCapabilities, SignatureHelpOptions, + TextDocumentSyncKind, Uri, WorkDoneProgressOptions, WorkspaceFolder, + WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities, }; use miette::{miette, IntoDiagnostic, Result}; use nu_protocol::{ ast::{Block, PathMember}, - engine::{Command, EngineState, StateDelta, StateWorkingSet}, + engine::{EngineState, StateDelta, StateWorkingSet}, DeclId, ModuleId, Span, Type, VarId, }; use std::{ @@ -31,6 +31,7 @@ mod completion; mod diagnostics; mod goto; mod hints; +mod hover; mod notification; mod semantic_tokens; mod signature; @@ -424,238 +425,21 @@ impl LanguageServer { }, } } - - fn get_decl_description(decl: &dyn Command, skip_description: bool) -> String { - let mut description = String::new(); - - if !skip_description { - // First description - description.push_str(&format!("{}\n", decl.description().replace('\r', ""))); - - // Additional description - if !decl.extra_description().is_empty() { - description.push_str(&format!("\n{}\n", decl.extra_description())); - } - } - // Usage - description.push_str("---\n### Usage \n```nu\n"); - let signature = decl.signature(); - description.push_str(&Self::get_signature_label(&signature)); - description.push_str("\n```\n"); - - // Flags - if !signature.named.is_empty() { - description.push_str("\n### Flags\n\n"); - let mut first = true; - for named in &signature.named { - if first { - first = false; - } else { - description.push('\n'); - } - description.push_str(" "); - if let Some(short_flag) = &named.short { - description.push_str(&format!("`-{short_flag}`")); - } - if !named.long.is_empty() { - if named.short.is_some() { - description.push_str(", "); - } - description.push_str(&format!("`--{}`", named.long)); - } - if let Some(arg) = &named.arg { - description.push_str(&format!(" `<{}>`", arg.to_type())); - } - if !named.desc.is_empty() { - description.push_str(&format!(" - {}", named.desc)); - } - description.push('\n'); - } - description.push('\n'); - } - - // Parameters - if !signature.required_positional.is_empty() - || !signature.optional_positional.is_empty() - || signature.rest_positional.is_some() - { - description.push_str("\n### Parameters\n\n"); - let mut first = true; - for required_arg in &signature.required_positional { - if first { - first = false; - } else { - description.push('\n'); - } - description.push_str(&format!( - " `{}: {}`", - required_arg.name, - required_arg.shape.to_type() - )); - if !required_arg.desc.is_empty() { - description.push_str(&format!(" - {}", required_arg.desc)); - } - description.push('\n'); - } - for optional_arg in &signature.optional_positional { - if first { - first = false; - } else { - description.push('\n'); - } - description.push_str(&format!( - " `{}: {}`", - optional_arg.name, - optional_arg.shape.to_type() - )); - if !optional_arg.desc.is_empty() { - description.push_str(&format!(" - {}", optional_arg.desc)); - } - description.push('\n'); - } - if let Some(arg) = &signature.rest_positional { - if !first { - description.push('\n'); - } - description.push_str(&format!(" `...{}: {}`", arg.name, arg.shape.to_type())); - if !arg.desc.is_empty() { - description.push_str(&format!(" - {}", arg.desc)); - } - description.push('\n'); - } - description.push('\n'); - } - - // Input/output types - if !signature.input_output_types.is_empty() { - description.push_str("\n### Input/output types\n"); - description.push_str("\n```nu\n"); - for input_output in &signature.input_output_types { - description.push_str(&format!(" {} | {}\n", input_output.0, input_output.1)); - } - description.push_str("\n```\n"); - } - - // Examples - if !decl.examples().is_empty() { - description.push_str("### Example(s)\n"); - for example in decl.examples() { - description.push_str(&format!( - " {}\n```nu\n {}\n```\n", - example.description, example.example - )); - } - } - description - } - - fn hover(&mut self, params: &HoverParams) -> Option { - let mut engine_state = self.new_engine_state(); - - let path_uri = params - .text_document_position_params - .text_document - .uri - .to_owned(); - let (working_set, id, _, _) = self - .parse_and_find( - &mut engine_state, - &path_uri, - params.text_document_position_params.position, - ) - .ok()?; - - let markdown_hover = |content: String| { - Some(Hover { - contents: HoverContents::Markup(MarkupContent { - kind: MarkupKind::Markdown, - value: content, - }), - // TODO - range: None, - }) - }; - - match id { - Id::Variable(var_id) => { - let var = working_set.get_variable(var_id); - let value = var - .const_val - .clone() - .and_then(|v| v.coerce_into_string().ok()) - .unwrap_or(String::from(if var.mutable { - "mutable" - } else { - "immutable" - })); - let contents = format!("```\n{}\n``` \n---\n{}", var.ty, value); - markdown_hover(contents) - } - Id::CellPath(var_id, cell_path) => { - let var = working_set.get_variable(var_id); - markdown_hover( - var.const_val - .clone() - .and_then(|val| val.follow_cell_path(&cell_path, false).ok()) - .map(|val| { - let ty = val.get_type().clone(); - let value_string = val - .coerce_into_string() - .ok() - .map(|s| format!("\n---\n{}", s)) - .unwrap_or_default(); - format!("```\n{}\n```{}", ty, value_string) - }) - .unwrap_or("`unknown`".into()), - ) - } - Id::Declaration(decl_id) => markdown_hover(Self::get_decl_description( - working_set.get_decl(decl_id), - false, - )), - Id::Module(module_id) => { - let description = working_set - .get_module_comments(module_id)? - .iter() - .map(|sp| String::from_utf8_lossy(working_set.get_span_contents(*sp)).into()) - .collect::>() - .join("\n"); - markdown_hover(description) - } - Id::Value(t) => markdown_hover(format!("`{}`", t)), - Id::External(cmd) => { - let command_output = if cfg!(windows) { - std::process::Command::new("powershell.exe") - .args(["-NoProfile", "-Command", "help", &cmd]) - .output() - } else { - std::process::Command::new("man").arg(&cmd).output() - }; - let manpage_str = match command_output { - Ok(output) => String::from_utf8_lossy(&output.stdout).to_string(), - Err(_) => format!("No command help found for {}", &cmd), - }; - markdown_hover(manpage_str) - } - } - } } #[cfg(test)] mod tests { use super::*; - use assert_json_diff::assert_json_eq; use lsp_types::{ notification::{ DidChangeTextDocument, DidOpenTextDocument, Exit, Initialized, Notification, }, request::{HoverRequest, Initialize, Request, Shutdown}, - DidChangeTextDocumentParams, DidOpenTextDocumentParams, InitializedParams, Position, + DidChangeTextDocumentParams, DidOpenTextDocumentParams, HoverParams, InitializedParams, TextDocumentContentChangeEvent, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, WorkDoneProgressParams, }; use nu_protocol::{debugger::WithoutDebug, engine::Stack, PipelineData, ShellError, Value}; - use nu_test_support::fs::fixtures; use std::sync::mpsc::{self, Receiver}; use std::time::Duration; @@ -879,179 +663,4 @@ mod tests { .recv_timeout(Duration::from_secs(2)) .unwrap() } - - #[test] - fn hover_on_variable() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("var.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 2, 0); - - assert_json_eq!( - result_from_message(resp), - serde_json::json!({ "contents": { "kind": "markdown", "value": "```\ntable\n``` \n---\nimmutable" } }) - ); - } - - #[test] - fn hover_on_cell_path() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("cell_path.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - - let resp = send_hover_request(&client_connection, script.clone(), 4, 3); - let result = result_from_message(resp); - assert_json_eq!( - result.pointer("/contents/value").unwrap(), - serde_json::json!("```\nlist\n```") - ); - - let resp = send_hover_request(&client_connection, script.clone(), 4, 7); - let result = result_from_message(resp); - assert_json_eq!( - result.pointer("/contents/value").unwrap(), - serde_json::json!("```\nrecord\n```") - ); - - let resp = send_hover_request(&client_connection, script.clone(), 4, 11); - let result = result_from_message(resp); - assert_json_eq!( - result.pointer("/contents/value").unwrap(), - serde_json::json!("```\nint\n```\n---\n2") - ); - } - - #[test] - fn hover_on_custom_command() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("command.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 3, 0); - - assert_json_eq!( - result_from_message(resp), - serde_json::json!({ - "contents": { - "kind": "markdown", - "value": "Renders some greeting message\n---\n### Usage \n```nu\n hello {flags}\n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n" - } - }) - ); - } - - #[test] - fn hover_on_custom_in_custom() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("command.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 9, 7); - - assert_json_eq!( - result_from_message(resp), - serde_json::json!({ - "contents": { - "kind": "markdown", - "value": "\n---\n### Usage \n```nu\n bar {flags}\n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n" - } - }) - ); - } - - #[test] - fn hover_on_external_command() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("command.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 6, 2); - - let hover_text = result_from_message(resp) - .pointer("/contents/value") - .unwrap() - .as_str() - .unwrap() - .to_string(); - - #[cfg(not(windows))] - assert!(hover_text.contains("SLEEP")); - #[cfg(windows)] - assert!(hover_text.contains("Start-Sleep")); - } - - #[test] - fn hover_on_str_join() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("hover"); - script.push("command.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 5, 8); - - assert_json_eq!( - result_from_message(resp), - serde_json::json!({ - "contents": { - "kind": "markdown", - "value": "Concatenate multiple strings into a single string, with an optional separator between each.\n---\n### Usage \n```nu\n str join {flags} \n```\n\n### Flags\n\n `-h`, `--help` - Display the help message for this command\n\n\n### Parameters\n\n `separator: string` - Optional separator to use when creating string.\n\n\n### Input/output types\n\n```nu\n list | string\n string | string\n\n```\n### Example(s)\n Create a string from input\n```nu\n ['nu', 'shell'] | str join\n```\n Create a string from input with a separator\n```nu\n ['nu', 'shell'] | str join '-'\n```\n" - } - }) - ); - } - - #[test] - fn hover_on_module() { - let (client_connection, _recv) = initialize_language_server(None, None); - - let mut script = fixtures(); - script.push("lsp"); - script.push("goto"); - script.push("module.nu"); - let script = path_to_uri(&script); - - open_unchecked(&client_connection, script.clone()); - let resp = send_hover_request(&client_connection, script.clone(), 3, 12); - let result = result_from_message(resp); - - assert_eq!( - result - .pointer("/contents/value") - .unwrap() - .to_string() - .replace("\\r", ""), - "\"# module doc\"" - ); - } } From f7f09292d6bc5be1cb8461b111bf8aed72dd047a Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Mon, 17 Mar 2025 20:22:01 +0800 Subject: [PATCH 28/59] Add category to pwd and banner commands (#15330) # Description Add category to `pwd` and `banner` commands, fix broken of command docs updating here: https://github.com/nushell/nushell.github.io/actions/runs/13884819349/job/38848104064#step:5:18 The error was caused by these two commands have no category --- crates/nu-std/std/prelude/mod.nu | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/nu-std/std/prelude/mod.nu b/crates/nu-std/std/prelude/mod.nu index 2080d3348e..84a2c9592a 100644 --- a/crates/nu-std/std/prelude/mod.nu +++ b/crates/nu-std/std/prelude/mod.nu @@ -1,6 +1,8 @@ use std/dt [datetime-diff, pretty-print-duration] # Print a banner for Nushell with information about the project +@category "default" +@search-terms "welcome" "startup" export def banner [ --short # Only show startup time ] { @@ -40,8 +42,9 @@ match (config use-colors) { } # Return the current working directory +@category "default" export def pwd [ - --physical (-P) # resolve symbolic links + --physical (-P) # Resolve symbolic links ] { if $physical { $env.PWD | path expand From 4cb195a998f157043c3b0a12021418a08c95226b Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Mon, 17 Mar 2025 09:16:17 -0400 Subject: [PATCH 29/59] Disallow DTD by default in `from xml` (#15325) # Description Follow-up to #15272, changing default to disallow DTD as discussed. Especially applicable for the `http get` case. # User-Facing Changes Changes behavior introduced in #15272, so release notes need to be updated to reflect this --- crates/nu-command/src/formats/from/xml.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/src/formats/from/xml.rs b/crates/nu-command/src/formats/from/xml.rs index 0c63d97c93..53c00ea0e0 100644 --- a/crates/nu-command/src/formats/from/xml.rs +++ b/crates/nu-command/src/formats/from/xml.rs @@ -17,8 +17,8 @@ impl Command for FromXml { .input_output_types(vec![(Type::String, Type::record())]) .switch("keep-comments", "add comment nodes to result", None) .switch( - "disallow-dtd", - "disallow parsing documents with DTDs (prevents exponential entity expansion attacks)", + "allow-dtd", + "allow parsing documents with DTDs (may result in exponential entity expansion)", None, ) .switch( @@ -55,7 +55,7 @@ string. This way content of every tag is always a table and is easier to parse"# let head = call.head; let keep_comments = call.has_flag(engine_state, stack, "keep-comments")?; let keep_processing_instructions = call.has_flag(engine_state, stack, "keep-pi")?; - let allow_dtd = !call.has_flag(engine_state, stack, "disallow-dtd")?; + let allow_dtd = call.has_flag(engine_state, stack, "allow-dtd")?; let info = ParsingInfo { span: head, keep_comments, @@ -278,7 +278,7 @@ fn process_xml_parse_error(source: String, err: roxmltree::Error, span: Span) -> make_xml_error("The root node was opened but never closed.", span) } roxmltree::Error::DtdDetected => make_xml_error( - "XML document with DTD detected.", + "XML document with DTD detected.\nDTDs are disabled by default to prevent denial-of-service attacks (use --allow-dtd to parse anyway)", span ), roxmltree::Error::NodesLimitReached => { From 90c86e6cbf7c74a5b9d14dd5bf49a0347ba4e2ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 03:44:50 +0000 Subject: [PATCH 30/59] build(deps): bump zip from 2.2.1 to 2.4.1 (#15335) Bumps [zip](https://github.com/zip-rs/zip2) from 2.2.1 to 2.4.1. --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e07c3cfa99..4f53269f61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1275,9 +1275,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crossterm" @@ -8571,9 +8571,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" +checksum = "938cc23ac49778ac8340e366ddc422b2227ea176edb447e23fc0627608dddadd" dependencies = [ "arbitrary", "crc32fast", From 9cca4ec18b69cc0e201e2b45bf286be950857356 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Tue, 18 Mar 2025 18:32:01 +0100 Subject: [PATCH 31/59] Pin reedline to `0.39.0` for release (#15338) --- Cargo.lock | 9 +++++---- Cargo.toml | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f53269f61..f403b27da9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -689,7 +689,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.11.0", + "itertools 0.13.0", "proc-macro2", "quote", "regex", @@ -5823,8 +5823,9 @@ dependencies = [ [[package]] name = "reedline" -version = "0.38.0" -source = "git+https://github.com/nushell/reedline?branch=main#dfdb167390bf9b550535cb8b5132e3122fd9f136" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4728ee71d2aa3a364ee64470d1aa64b3f0467b2d28b73df15259d005dec64a" dependencies = [ "arboard", "chrono", @@ -8058,7 +8059,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 316c825b63..b9f4b2ecdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,7 @@ getrandom = "0.2" # pick same version that rand requires rand_chacha = "0.3.1" ratatui = "0.29" rayon = "1.10" -reedline = "0.38.0" +reedline = "0.39.0" rmp = "0.8" rmp-serde = "1.3" roxmltree = "0.20" @@ -323,7 +323,7 @@ bench = false # 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 [patch.crates-io] -reedline = { git = "https://github.com/nushell/reedline", branch = "main" } +# reedline = { git = "https://github.com/nushell/reedline", branch = "main" } # nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"} # Run all benchmarks with `cargo bench` From 09674a0026b619b801805996fa7f5ae37062aa0e Mon Sep 17 00:00:00 2001 From: Yash Thakur <45539777+ysthakur@users.noreply.github.com> Date: Tue, 18 Mar 2025 19:02:04 -0400 Subject: [PATCH 32/59] Feature-gate `job unfreeze` behind "os" (#15339) # Description The `job unfreeze` command relies on the `os` feature of the `nu-protocol` crate, which means that `nu-command` doesn't compile with `--no-default-features`. This PR gates `job unfreeze` behind `nu-command`'s `os` feature to avoid this. No user-facing changes, no tests needed. --- crates/nu-command/src/default_context.rs | 2 +- crates/nu-command/src/experimental/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index dfd7badbec..0c1b38182a 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -454,7 +454,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { Job, }; - #[cfg(unix)] + #[cfg(all(unix, feature = "os"))] bind_command! { JobUnfreeze, } diff --git a/crates/nu-command/src/experimental/mod.rs b/crates/nu-command/src/experimental/mod.rs index 867cd6457e..ff4f6b0399 100644 --- a/crates/nu-command/src/experimental/mod.rs +++ b/crates/nu-command/src/experimental/mod.rs @@ -4,7 +4,7 @@ mod job_kill; mod job_list; mod job_spawn; -#[cfg(unix)] +#[cfg(all(unix, feature = "os"))] mod job_unfreeze; pub use is_admin::IsAdmin; @@ -14,5 +14,5 @@ pub use job_list::JobList; pub use job_spawn::JobSpawn; -#[cfg(unix)] +#[cfg(all(unix, feature = "os"))] pub use job_unfreeze::JobUnfreeze; From c98642647878b4f66fb7e38388a3973071b0e27b Mon Sep 17 00:00:00 2001 From: Yash Thakur <45539777+ysthakur@users.noreply.github.com> Date: Tue, 18 Mar 2025 20:12:52 -0400 Subject: [PATCH 33/59] Bump version for 0.103.0 release (#15340) --- Cargo.lock | 74 +++++++++---------- Cargo.toml | 40 +++++----- crates/nu-cli/Cargo.toml | 26 +++---- crates/nu-cmd-base/Cargo.toml | 10 +-- crates/nu-cmd-extra/Cargo.toml | 22 +++--- crates/nu-cmd-lang/Cargo.toml | 10 +-- crates/nu-cmd-plugin/Cargo.toml | 10 +-- crates/nu-color-config/Cargo.toml | 10 +-- crates/nu-command/Cargo.toml | 34 ++++----- crates/nu-derive-value/Cargo.toml | 2 +- crates/nu-engine/Cargo.toml | 10 +-- crates/nu-explore/Cargo.toml | 20 ++--- crates/nu-glob/Cargo.toml | 4 +- crates/nu-json/Cargo.toml | 6 +- crates/nu-lsp/Cargo.toml | 20 ++--- crates/nu-parser/Cargo.toml | 12 +-- crates/nu-path/Cargo.toml | 2 +- crates/nu-plugin-core/Cargo.toml | 6 +- crates/nu-plugin-engine/Cargo.toml | 14 ++-- crates/nu-plugin-protocol/Cargo.toml | 6 +- crates/nu-plugin-test-support/Cargo.toml | 18 ++--- crates/nu-plugin/Cargo.toml | 12 +-- crates/nu-pretty-hex/Cargo.toml | 2 +- crates/nu-protocol/Cargo.toml | 14 ++-- crates/nu-std/Cargo.toml | 8 +- crates/nu-system/Cargo.toml | 2 +- crates/nu-table/Cargo.toml | 12 +-- crates/nu-term-grid/Cargo.toml | 4 +- crates/nu-test-support/Cargo.toml | 8 +- crates/nu-utils/Cargo.toml | 2 +- .../src/default_files/default_config.nu | 2 +- .../nu-utils/src/default_files/default_env.nu | 2 +- .../nu-utils/src/default_files/doc_config.nu | 2 +- crates/nu-utils/src/default_files/doc_env.nu | 2 +- .../src/default_files/scaffold_config.nu | 2 +- .../src/default_files/scaffold_env.nu | 2 +- crates/nu_plugin_custom_values/Cargo.toml | 6 +- crates/nu_plugin_example/Cargo.toml | 10 +-- crates/nu_plugin_formats/Cargo.toml | 8 +- crates/nu_plugin_gstat/Cargo.toml | 6 +- crates/nu_plugin_inc/Cargo.toml | 6 +- .../nu_plugin_nu_example.nu | 2 +- crates/nu_plugin_polars/Cargo.toml | 20 ++--- .../nu_plugin_python_example.py | 2 +- crates/nu_plugin_query/Cargo.toml | 6 +- crates/nu_plugin_stress_internals/Cargo.toml | 2 +- crates/nuon/Cargo.toml | 10 +-- 47 files changed, 255 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f403b27da9..76a98fc073 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "nu" -version = "0.102.1" +version = "0.103.0" dependencies = [ "assert_cmd", "crossterm", @@ -3501,7 +3501,7 @@ dependencies = [ [[package]] name = "nu-cli" -version = "0.102.1" +version = "0.103.0" dependencies = [ "chrono", "crossterm", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "nu-cmd-base" -version = "0.102.1" +version = "0.103.0" dependencies = [ "indexmap", "miette", @@ -3549,7 +3549,7 @@ dependencies = [ [[package]] name = "nu-cmd-extra" -version = "0.102.1" +version = "0.103.0" dependencies = [ "fancy-regex", "heck", @@ -3575,7 +3575,7 @@ dependencies = [ [[package]] name = "nu-cmd-lang" -version = "0.102.1" +version = "0.103.0" dependencies = [ "itertools 0.13.0", "nu-engine", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "nu-cmd-plugin" -version = "0.102.1" +version = "0.103.0" dependencies = [ "itertools 0.13.0", "nu-engine", @@ -3600,7 +3600,7 @@ dependencies = [ [[package]] name = "nu-color-config" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-ansi-term", "nu-engine", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "nu-command" -version = "0.102.1" +version = "0.103.0" dependencies = [ "alphanumeric-sort", "base64 0.22.1", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "nu-derive-value" -version = "0.102.1" +version = "0.103.0" dependencies = [ "heck", "proc-macro-error2", @@ -3736,7 +3736,7 @@ dependencies = [ [[package]] name = "nu-engine" -version = "0.102.1" +version = "0.103.0" dependencies = [ "log", "nu-glob", @@ -3747,7 +3747,7 @@ dependencies = [ [[package]] name = "nu-explore" -version = "0.102.1" +version = "0.103.0" dependencies = [ "ansi-str", "anyhow", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "nu-glob" -version = "0.102.1" +version = "0.103.0" dependencies = [ "doc-comment", "nu-protocol", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "nu-json" -version = "0.102.1" +version = "0.103.0" dependencies = [ "fancy-regex", "linked-hash-map", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "nu-lsp" -version = "0.102.1" +version = "0.103.0" dependencies = [ "assert-json-diff", "crossbeam-channel", @@ -3817,7 +3817,7 @@ dependencies = [ [[package]] name = "nu-parser" -version = "0.102.1" +version = "0.103.0" dependencies = [ "bytesize", "chrono", @@ -3834,7 +3834,7 @@ dependencies = [ [[package]] name = "nu-path" -version = "0.102.1" +version = "0.103.0" dependencies = [ "dirs", "omnipath", @@ -3844,7 +3844,7 @@ dependencies = [ [[package]] name = "nu-plugin" -version = "0.102.1" +version = "0.103.0" dependencies = [ "log", "nix 0.29.0", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "nu-plugin-core" -version = "0.102.1" +version = "0.103.0" dependencies = [ "interprocess", "log", @@ -3874,7 +3874,7 @@ dependencies = [ [[package]] name = "nu-plugin-engine" -version = "0.102.1" +version = "0.103.0" dependencies = [ "log", "nu-engine", @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "nu-plugin-protocol" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-protocol", "nu-utils", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "nu-plugin-test-support" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-ansi-term", "nu-cmd-lang", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "nu-pretty-hex" -version = "0.102.1" +version = "0.103.0" dependencies = [ "heapless", "nu-ansi-term", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "nu-protocol" -version = "0.102.1" +version = "0.103.0" dependencies = [ "brotli", "bytes", @@ -3968,7 +3968,7 @@ dependencies = [ [[package]] name = "nu-std" -version = "0.102.1" +version = "0.103.0" dependencies = [ "log", "miette", @@ -3979,7 +3979,7 @@ dependencies = [ [[package]] name = "nu-system" -version = "0.102.1" +version = "0.103.0" dependencies = [ "chrono", "itertools 0.13.0", @@ -3997,7 +3997,7 @@ dependencies = [ [[package]] name = "nu-table" -version = "0.102.1" +version = "0.103.0" dependencies = [ "fancy-regex", "nu-ansi-term", @@ -4010,7 +4010,7 @@ dependencies = [ [[package]] name = "nu-term-grid" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-utils", "unicode-width 0.2.0", @@ -4018,7 +4018,7 @@ dependencies = [ [[package]] name = "nu-test-support" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-glob", "nu-path", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "nu-utils" -version = "0.102.1" +version = "0.103.0" dependencies = [ "crossterm", "crossterm_winapi", @@ -4059,7 +4059,7 @@ dependencies = [ [[package]] name = "nu_plugin_example" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-cmd-lang", "nu-plugin", @@ -4069,7 +4069,7 @@ dependencies = [ [[package]] name = "nu_plugin_formats" -version = "0.102.1" +version = "0.103.0" dependencies = [ "chrono", "eml-parser", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "nu_plugin_gstat" -version = "0.102.1" +version = "0.103.0" dependencies = [ "git2", "nu-plugin", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "nu_plugin_inc" -version = "0.102.1" +version = "0.103.0" dependencies = [ "nu-plugin", "nu-protocol", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "nu_plugin_polars" -version = "0.102.1" +version = "0.103.0" dependencies = [ "aws-config", "aws-credential-types", @@ -4141,7 +4141,7 @@ dependencies = [ [[package]] name = "nu_plugin_query" -version = "0.102.1" +version = "0.103.0" dependencies = [ "gjson", "nu-plugin", @@ -4156,7 +4156,7 @@ dependencies = [ [[package]] name = "nu_plugin_stress_internals" -version = "0.102.1" +version = "0.103.0" dependencies = [ "interprocess", "serde", @@ -4280,7 +4280,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nuon" -version = "0.102.1" +version = "0.103.0" dependencies = [ "chrono", "nu-engine", diff --git a/Cargo.toml b/Cargo.toml index b9f4b2ecdc..64786bdaba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" name = "nu" repository = "https://github.com/nushell/nushell" rust-version = "1.83.0" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -197,22 +197,22 @@ unchecked_duration_subtraction = "warn" workspace = true [dependencies] -nu-cli = { path = "./crates/nu-cli", version = "0.102.1" } -nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.102.1" } -nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.102.1" } -nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.102.1", optional = true } -nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.102.1" } -nu-command = { path = "./crates/nu-command", version = "0.102.1" } -nu-engine = { path = "./crates/nu-engine", version = "0.102.1" } -nu-explore = { path = "./crates/nu-explore", version = "0.102.1" } -nu-lsp = { path = "./crates/nu-lsp/", version = "0.102.1" } -nu-parser = { path = "./crates/nu-parser", version = "0.102.1" } -nu-path = { path = "./crates/nu-path", version = "0.102.1" } -nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.102.1" } -nu-protocol = { path = "./crates/nu-protocol", version = "0.102.1" } -nu-std = { path = "./crates/nu-std", version = "0.102.1" } -nu-system = { path = "./crates/nu-system", version = "0.102.1" } -nu-utils = { path = "./crates/nu-utils", version = "0.102.1" } +nu-cli = { path = "./crates/nu-cli", version = "0.103.0" } +nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.103.0" } +nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.103.0" } +nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.103.0", optional = true } +nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.103.0" } +nu-command = { path = "./crates/nu-command", version = "0.103.0" } +nu-engine = { path = "./crates/nu-engine", version = "0.103.0" } +nu-explore = { path = "./crates/nu-explore", version = "0.103.0" } +nu-lsp = { path = "./crates/nu-lsp/", version = "0.103.0" } +nu-parser = { path = "./crates/nu-parser", version = "0.103.0" } +nu-path = { path = "./crates/nu-path", version = "0.103.0" } +nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.103.0" } +nu-protocol = { path = "./crates/nu-protocol", version = "0.103.0" } +nu-std = { path = "./crates/nu-std", version = "0.103.0" } +nu-system = { path = "./crates/nu-system", version = "0.103.0" } +nu-utils = { path = "./crates/nu-utils", version = "0.103.0" } reedline = { workspace = true, features = ["bashisms", "sqlite"] } crossterm = { workspace = true } @@ -241,9 +241,9 @@ nix = { workspace = true, default-features = false, features = [ ] } [dev-dependencies] -nu-test-support = { path = "./crates/nu-test-support", version = "0.102.1" } -nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.102.1" } -nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.102.1" } +nu-test-support = { path = "./crates/nu-test-support", version = "0.103.0" } +nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.103.0" } +nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.103.0" } assert_cmd = "2.0" dirs = { workspace = true } tango-bench = "0.6" diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 039ebdd398..41d2ef25e5 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -5,28 +5,28 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli" edition = "2021" license = "MIT" name = "nu-cli" -version = "0.102.1" +version = "0.103.0" [lib] bench = false [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } -nu-command = { path = "../nu-command", version = "0.102.1" } -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-command = { path = "../nu-command", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } rstest = { workspace = true, default-features = false } tempfile = { workspace = true } [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1", features = ["os"] } -nu-glob = { path = "../nu-glob", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.102.1", optional = true } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["os"] } -nu-utils = { path = "../nu-utils", version = "0.102.1" } -nu-color-config = { path = "../nu-color-config", version = "0.102.1" } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["os"] } +nu-glob = { path = "../nu-glob", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0", optional = true } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["os"] } +nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-color-config = { path = "../nu-color-config", version = "0.103.0" } nu-ansi-term = { workspace = true } reedline = { workspace = true, features = ["bashisms", "sqlite"] } diff --git a/crates/nu-cmd-base/Cargo.toml b/crates/nu-cmd-base/Cargo.toml index fa73f6d015..1af9be44d3 100644 --- a/crates/nu-cmd-base/Cargo.toml +++ b/crates/nu-cmd-base/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-base" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,10 +13,10 @@ version = "0.102.1" workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } indexmap = { workspace = true } miette = { workspace = true } diff --git a/crates/nu-cmd-extra/Cargo.toml b/crates/nu-cmd-extra/Cargo.toml index 6fa95a3949..83aab0d165 100644 --- a/crates/nu-cmd-extra/Cargo.toml +++ b/crates/nu-cmd-extra/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-extra" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,13 +16,13 @@ bench = false workspace = true [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-json = { version = "0.102.1", path = "../nu-json" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-pretty-hex = { version = "0.102.1", path = "../nu-pretty-hex" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-json = { version = "0.103.0", path = "../nu-json" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-pretty-hex = { version = "0.103.0", path = "../nu-pretty-hex" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } # Potential dependencies for extras heck = { workspace = true } @@ -37,6 +37,6 @@ itertools = { workspace = true } mime = { workspace = true } [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } -nu-command = { path = "../nu-command", version = "0.102.1" } -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-command = { path = "../nu-command", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } diff --git a/crates/nu-cmd-lang/Cargo.toml b/crates/nu-cmd-lang/Cargo.toml index e505a1c853..76691e6180 100644 --- a/crates/nu-cmd-lang/Cargo.toml +++ b/crates/nu-cmd-lang/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang" edition = "2021" license = "MIT" name = "nu-cmd-lang" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -15,10 +15,10 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } itertools = { workspace = true } shadow-rs = { version = "0.38", default-features = false } diff --git a/crates/nu-cmd-plugin/Cargo.toml b/crates/nu-cmd-plugin/Cargo.toml index 3618a6a584..265721cdcf 100644 --- a/crates/nu-cmd-plugin/Cargo.toml +++ b/crates/nu-cmd-plugin/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-plugin" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,10 +13,10 @@ version = "0.102.1" workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.102.1" } +nu-engine = { path = "../nu-engine", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0" } itertools = { workspace = true } diff --git a/crates/nu-color-config/Cargo.toml b/crates/nu-color-config/Cargo.toml index 4702443b00..060fe49a63 100644 --- a/crates/nu-color-config/Cargo.toml +++ b/crates/nu-color-config/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi edition = "2021" license = "MIT" name = "nu-color-config" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,12 +14,12 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-json = { path = "../nu-json", version = "0.102.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-json = { path = "../nu-json", version = "0.103.0" } nu-ansi-term = { workspace = true } serde = { workspace = true, features = ["derive"] } [dev-dependencies] -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } \ No newline at end of file +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } \ No newline at end of file diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 8ade47af0e..77169ab661 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-command" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,21 +16,21 @@ bench = false workspace = true [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.102.1" } -nu-color-config = { path = "../nu-color-config", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-glob = { path = "../nu-glob", version = "0.102.1" } -nu-json = { path = "../nu-json", version = "0.102.1" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-system = { path = "../nu-system", version = "0.102.1" } -nu-table = { path = "../nu-table", version = "0.102.1" } -nu-term-grid = { path = "../nu-term-grid", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } +nu-color-config = { path = "../nu-color-config", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-glob = { path = "../nu-glob", version = "0.103.0" } +nu-json = { path = "../nu-json", version = "0.103.0" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-system = { path = "../nu-system", version = "0.103.0" } +nu-table = { path = "../nu-table", version = "0.103.0" } +nu-term-grid = { path = "../nu-term-grid", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } nu-ansi-term = { workspace = true } -nuon = { path = "../nuon", version = "0.102.1" } +nuon = { path = "../nuon", version = "0.103.0" } alphanumeric-sort = { workspace = true } base64 = { workspace = true } @@ -209,8 +209,8 @@ sqlite = ["rusqlite"] trash-support = ["trash"] [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } dirs = { workspace = true } mockito = { workspace = true, default-features = false } diff --git a/crates/nu-derive-value/Cargo.toml b/crates/nu-derive-value/Cargo.toml index a8b25de68c..f4e032844f 100644 --- a/crates/nu-derive-value/Cargo.toml +++ b/crates/nu-derive-value/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-derive-value" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-derive-value" -version = "0.102.1" +version = "0.103.0" [lib] proc-macro = true diff --git a/crates/nu-engine/Cargo.toml b/crates/nu-engine/Cargo.toml index 39ff1e4954..1c40cefeaa 100644 --- a/crates/nu-engine/Cargo.toml +++ b/crates/nu-engine/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine" edition = "2021" license = "MIT" name = "nu-engine" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,10 +14,10 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-glob = { path = "../nu-glob", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-glob = { path = "../nu-glob", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } log = { workspace = true } [features] diff --git a/crates/nu-explore/Cargo.toml b/crates/nu-explore/Cargo.toml index bf6f4c8225..3f64922e22 100644 --- a/crates/nu-explore/Cargo.toml +++ b/crates/nu-explore/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-explore" edition = "2021" license = "MIT" name = "nu-explore" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,16 +14,16 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-color-config = { path = "../nu-color-config", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1" } -nu-table = { path = "../nu-table", version = "0.102.1" } -nu-json = { path = "../nu-json", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-color-config = { path = "../nu-color-config", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0" } +nu-table = { path = "../nu-table", version = "0.103.0" } +nu-json = { path = "../nu-json", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0" } nu-ansi-term = { workspace = true } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.102.1" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.0" } anyhow = { workspace = true } log = { workspace = true } diff --git a/crates/nu-glob/Cargo.toml b/crates/nu-glob/Cargo.toml index ec38717371..1d4f6da5da 100644 --- a/crates/nu-glob/Cargo.toml +++ b/crates/nu-glob/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu-glob" -version = "0.102.1" +version = "0.103.0" authors = ["The Nushell Project Developers", "The Rust Project Developers"] license = "MIT/Apache-2.0" description = """ @@ -14,7 +14,7 @@ categories = ["filesystem"] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } [dev-dependencies] doc-comment = "0.3" diff --git a/crates/nu-json/Cargo.toml b/crates/nu-json/Cargo.toml index 92dabeae13..d6beb7aa59 100644 --- a/crates/nu-json/Cargo.toml +++ b/crates/nu-json/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-json" edition = "2021" license = "MIT" name = "nu-json" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -26,8 +26,8 @@ serde = { workspace = true } serde_json = { workspace = true } [dev-dependencies] -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } serde_json = "1.0" fancy-regex = "0.14.0" diff --git a/crates/nu-lsp/Cargo.toml b/crates/nu-lsp/Cargo.toml index 1ec37ee844..a23d916f99 100644 --- a/crates/nu-lsp/Cargo.toml +++ b/crates/nu-lsp/Cargo.toml @@ -3,16 +3,16 @@ authors = ["The Nushell Project Developers"] description = "Nushell's integrated LSP server" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-lsp" name = "nu-lsp" -version = "0.102.1" +version = "0.103.0" edition = "2021" license = "MIT" [dependencies] -nu-cli = { path = "../nu-cli", version = "0.102.1" } -nu-glob = { path = "../nu-glob", version = "0.102.1" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-cli = { path = "../nu-cli", version = "0.103.0" } +nu-glob = { path = "../nu-glob", version = "0.103.0" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0" } crossbeam-channel = { workspace = true } lsp-server = { workspace = true } @@ -25,10 +25,10 @@ serde_json = { workspace = true } url = { workspace = true } [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } -nu-command = { path = "../nu-command", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1" } -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-command = { path = "../nu-command", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } assert-json-diff = "2.0" diff --git a/crates/nu-parser/Cargo.toml b/crates/nu-parser/Cargo.toml index 967d610444..924539bdb6 100644 --- a/crates/nu-parser/Cargo.toml +++ b/crates/nu-parser/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-parser" edition = "2021" license = "MIT" name = "nu-parser" -version = "0.102.1" +version = "0.103.0" exclude = ["/fuzz"] [lib] @@ -15,11 +15,11 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } bytesize = { workspace = true } chrono = { default-features = false, features = ['std'], workspace = true } diff --git a/crates/nu-path/Cargo.toml b/crates/nu-path/Cargo.toml index 33199de15a..c4a628e2d5 100644 --- a/crates/nu-path/Cargo.toml +++ b/crates/nu-path/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-path" edition = "2021" license = "MIT" name = "nu-path" -version = "0.102.1" +version = "0.103.0" exclude = ["/fuzz"] [lib] diff --git a/crates/nu-plugin-core/Cargo.toml b/crates/nu-plugin-core/Cargo.toml index bd0642e0fe..404a350d8c 100644 --- a/crates/nu-plugin-core/Cargo.toml +++ b/crates/nu-plugin-core/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-core edition = "2021" license = "MIT" name = "nu-plugin-core" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,8 +14,8 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.102.1", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0", default-features = false } rmp-serde = { workspace = true } serde = { workspace = true } diff --git a/crates/nu-plugin-engine/Cargo.toml b/crates/nu-plugin-engine/Cargo.toml index 90d166510c..42f2f80687 100644 --- a/crates/nu-plugin-engine/Cargo.toml +++ b/crates/nu-plugin-engine/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-engi edition = "2021" license = "MIT" name = "nu-plugin-engine" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,12 +14,12 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } -nu-system = { path = "../nu-system", version = "0.102.1" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.102.1" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-engine = { path = "../nu-engine", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-system = { path = "../nu-system", version = "0.103.0" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0" } serde = { workspace = true } log = { workspace = true } diff --git a/crates/nu-plugin-protocol/Cargo.toml b/crates/nu-plugin-protocol/Cargo.toml index 36b00e29aa..892877ae5d 100644 --- a/crates/nu-plugin-protocol/Cargo.toml +++ b/crates/nu-plugin-protocol/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-prot edition = "2021" license = "MIT" name = "nu-plugin-protocol" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,8 +14,8 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-utils = { path = "../nu-utils", version = "0.103.0" } rmp-serde = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/nu-plugin-test-support/Cargo.toml b/crates/nu-plugin-test-support/Cargo.toml index 1e63b65de6..98b33bb8ce 100644 --- a/crates/nu-plugin-test-support/Cargo.toml +++ b/crates/nu-plugin-test-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu-plugin-test-support" -version = "0.102.1" +version = "0.103.0" edition = "2021" license = "MIT" description = "Testing support for Nushell plugins" @@ -15,14 +15,14 @@ workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1", features = ["plugin"] } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } -nu-parser = { path = "../nu-parser", version = "0.102.1", features = ["plugin"] } -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.102.1" } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.102.1" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.102.1" } -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } +nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["plugin"] } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-parser = { path = "../nu-parser", version = "0.103.0", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0" } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } nu-ansi-term = { workspace = true } similar = "2.7" diff --git a/crates/nu-plugin/Cargo.toml b/crates/nu-plugin/Cargo.toml index 083946933a..e5486133e5 100644 --- a/crates/nu-plugin/Cargo.toml +++ b/crates/nu-plugin/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin" edition = "2021" license = "MIT" name = "nu-plugin" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,11 +14,11 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.102.1", features = ["plugin"] } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.102.1" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["plugin"] } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0" } log = { workspace = true } thiserror = "2.0" diff --git a/crates/nu-pretty-hex/Cargo.toml b/crates/nu-pretty-hex/Cargo.toml index 4397f7bb3a..ac3f774b8d 100644 --- a/crates/nu-pretty-hex/Cargo.toml +++ b/crates/nu-pretty-hex/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-pretty-hex" edition = "2021" license = "MIT" name = "nu-pretty-hex" -version = "0.102.1" +version = "0.103.0" [lib] doctest = false diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml index 9050037cd3..d1ef23d699 100644 --- a/crates/nu-protocol/Cargo.toml +++ b/crates/nu-protocol/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-protocol" edition = "2021" license = "MIT" name = "nu-protocol" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,10 +16,10 @@ bench = false workspace = true [dependencies] -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-system = { path = "../nu-system", version = "0.102.1" } -nu-derive-value = { path = "../nu-derive-value", version = "0.102.1" } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-system = { path = "../nu-system", version = "0.103.0" } +nu-derive-value = { path = "../nu-derive-value", version = "0.103.0" } brotli = { workspace = true, optional = true } bytes = { workspace = true } @@ -66,8 +66,8 @@ plugin = [ [dev-dependencies] serde_json = { workspace = true } -nu-test-support = { path = "../nu-test-support", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0" } pretty_assertions = { workspace = true } rstest = { workspace = true } tempfile = { workspace = true } diff --git a/crates/nu-std/Cargo.toml b/crates/nu-std/Cargo.toml index ffab3bc9cd..2d703263d8 100644 --- a/crates/nu-std/Cargo.toml +++ b/crates/nu-std/Cargo.toml @@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-std" edition = "2021" license = "MIT" name = "nu-std" -version = "0.102.1" +version = "0.103.0" [dependencies] -nu-parser = { version = "0.102.1", path = "../nu-parser" } -nu-protocol = { version = "0.102.1", path = "../nu-protocol", default-features = false } -nu-engine = { version = "0.102.1", path = "../nu-engine", default-features = false } +nu-parser = { version = "0.103.0", path = "../nu-parser" } +nu-protocol = { version = "0.103.0", path = "../nu-protocol", default-features = false } +nu-engine = { version = "0.103.0", path = "../nu-engine", default-features = false } miette = { workspace = true, features = ["fancy-no-backtrace"] } log = "0.4" diff --git a/crates/nu-system/Cargo.toml b/crates/nu-system/Cargo.toml index fac29b7715..2a8d48865d 100644 --- a/crates/nu-system/Cargo.toml +++ b/crates/nu-system/Cargo.toml @@ -3,7 +3,7 @@ authors = ["The Nushell Project Developers", "procs creators"] description = "Nushell system querying" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-system" name = "nu-system" -version = "0.102.1" +version = "0.103.0" edition = "2021" license = "MIT" diff --git a/crates/nu-table/Cargo.toml b/crates/nu-table/Cargo.toml index 27a752c217..889a5d4d6e 100644 --- a/crates/nu-table/Cargo.toml +++ b/crates/nu-table/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-table" edition = "2021" license = "MIT" name = "nu-table" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,13 +14,13 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-color-config = { path = "../nu-color-config", version = "0.102.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-color-config = { path = "../nu-color-config", version = "0.103.0" } nu-ansi-term = { workspace = true } fancy-regex = { workspace = true } tabled = { workspace = true, features = ["ansi"], default-features = false } [dev-dependencies] -# nu-test-support = { path="../nu-test-support", version = "0.102.1" } \ No newline at end of file +# nu-test-support = { path="../nu-test-support", version = "0.103.0" } \ No newline at end of file diff --git a/crates/nu-term-grid/Cargo.toml b/crates/nu-term-grid/Cargo.toml index 51a47f985c..1918e91235 100644 --- a/crates/nu-term-grid/Cargo.toml +++ b/crates/nu-term-grid/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-term-grid" edition = "2021" license = "MIT" name = "nu-term-grid" -version = "0.102.1" +version = "0.103.0" [lib] bench = false @@ -14,6 +14,6 @@ bench = false workspace = true [dependencies] -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } unicode-width = { workspace = true } \ No newline at end of file diff --git a/crates/nu-test-support/Cargo.toml b/crates/nu-test-support/Cargo.toml index ff5bd2ba0f..a78e4dca61 100644 --- a/crates/nu-test-support/Cargo.toml +++ b/crates/nu-test-support/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-test-suppor edition = "2021" license = "MIT" name = "nu-test-support" -version = "0.102.1" +version = "0.103.0" [lib] doctest = false @@ -15,9 +15,9 @@ bench = false workspace = true [dependencies] -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-glob = { path = "../nu-glob", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-glob = { path = "../nu-glob", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0" } num-format = { workspace = true } which = { workspace = true } diff --git a/crates/nu-utils/Cargo.toml b/crates/nu-utils/Cargo.toml index 0e146d21f1..d9a88bcea5 100644 --- a/crates/nu-utils/Cargo.toml +++ b/crates/nu-utils/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-utils" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-utils" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [[bin]] diff --git a/crates/nu-utils/src/default_files/default_config.nu b/crates/nu-utils/src/default_files/default_config.nu index 8998c980d1..6d0fd3cb15 100644 --- a/crates/nu-utils/src/default_files/default_config.nu +++ b/crates/nu-utils/src/default_files/default_config.nu @@ -1,6 +1,6 @@ # Nushell Config File # -# version = "0.102.1" +# version = "0.103.0" $env.config.color_config = { separator: white leading_trailing_space_bg: { attr: n } diff --git a/crates/nu-utils/src/default_files/default_env.nu b/crates/nu-utils/src/default_files/default_env.nu index f4582825c0..7b18561179 100644 --- a/crates/nu-utils/src/default_files/default_env.nu +++ b/crates/nu-utils/src/default_files/default_env.nu @@ -1,7 +1,7 @@ # Default Nushell Environment Config File # These "sensible defaults" are set before the user's `env.nu` is loaded # -# version = "0.102.1" +# version = "0.103.0" $env.PROMPT_COMMAND = {|| let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) { diff --git a/crates/nu-utils/src/default_files/doc_config.nu b/crates/nu-utils/src/default_files/doc_config.nu index d2a4d5195e..d2d3bc5708 100644 --- a/crates/nu-utils/src/default_files/doc_config.nu +++ b/crates/nu-utils/src/default_files/doc_config.nu @@ -3,7 +3,7 @@ # Warning: This file is intended for documentation purposes only and # is not intended to be used as an actual configuration file as-is. # -# version = "0.102.1" +# version = "0.103.0" # # A `config.nu` file is used to override default Nushell settings, # define (or import) custom commands, or run any other startup tasks. diff --git a/crates/nu-utils/src/default_files/doc_env.nu b/crates/nu-utils/src/default_files/doc_env.nu index 43cb12904d..6d639146e1 100644 --- a/crates/nu-utils/src/default_files/doc_env.nu +++ b/crates/nu-utils/src/default_files/doc_env.nu @@ -1,6 +1,6 @@ # Nushell Environment Config File Documentation # -# version = "0.102.1" +# version = "0.103.0" # # Previously, environment variables were typically configured in `env.nu`. # In general, most configuration can and should be performed in `config.nu` diff --git a/crates/nu-utils/src/default_files/scaffold_config.nu b/crates/nu-utils/src/default_files/scaffold_config.nu index 100f56a233..ca44a41929 100644 --- a/crates/nu-utils/src/default_files/scaffold_config.nu +++ b/crates/nu-utils/src/default_files/scaffold_config.nu @@ -1,7 +1,7 @@ # config.nu # # Installed by: -# version = "0.102.1" +# version = "0.103.0" # # This file is used to override default Nushell settings, define # (or import) custom commands, or run any other startup tasks. diff --git a/crates/nu-utils/src/default_files/scaffold_env.nu b/crates/nu-utils/src/default_files/scaffold_env.nu index 83e83e2028..2a6217eb6b 100644 --- a/crates/nu-utils/src/default_files/scaffold_env.nu +++ b/crates/nu-utils/src/default_files/scaffold_env.nu @@ -1,7 +1,7 @@ # env.nu # # Installed by: -# version = "0.102.1" +# version = "0.103.0" # # Previously, environment variables were typically configured in `env.nu`. # In general, most configuration can and should be performed in `config.nu` diff --git a/crates/nu_plugin_custom_values/Cargo.toml b/crates/nu_plugin_custom_values/Cargo.toml index fe5e2e8acb..fd05381f79 100644 --- a/crates/nu_plugin_custom_values/Cargo.toml +++ b/crates/nu_plugin_custom_values/Cargo.toml @@ -10,10 +10,10 @@ name = "nu_plugin_custom_values" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1", features = [] } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.0", features = [] } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } serde = { workspace = true } typetag = "0.2" [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.102.1" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } \ No newline at end of file diff --git a/crates/nu_plugin_example/Cargo.toml b/crates/nu_plugin_example/Cargo.toml index 681eadf3cb..d685a881c9 100644 --- a/crates/nu_plugin_example/Cargo.toml +++ b/crates/nu_plugin_example/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_exam edition = "2021" license = "MIT" name = "nu_plugin_example" -version = "0.102.1" +version = "0.103.0" [[bin]] name = "nu_plugin_example" @@ -15,9 +15,9 @@ bench = false bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.102.1" } -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } \ No newline at end of file diff --git a/crates/nu_plugin_formats/Cargo.toml b/crates/nu_plugin_formats/Cargo.toml index 6f5101e2d5..2cff18c69c 100644 --- a/crates/nu_plugin_formats/Cargo.toml +++ b/crates/nu_plugin_formats/Cargo.toml @@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_form edition = "2021" license = "MIT" name = "nu_plugin_formats" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } indexmap = { workspace = true } eml-parser = "0.1" @@ -20,4 +20,4 @@ plist = "1.7" chrono = "0.4" [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.102.1" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } \ No newline at end of file diff --git a/crates/nu_plugin_gstat/Cargo.toml b/crates/nu_plugin_gstat/Cargo.toml index 69a704862e..82c8268b6c 100644 --- a/crates/nu_plugin_gstat/Cargo.toml +++ b/crates/nu_plugin_gstat/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_gsta edition = "2021" license = "MIT" name = "nu_plugin_gstat" -version = "0.102.1" +version = "0.103.0" [lib] doctest = false @@ -16,7 +16,7 @@ name = "nu_plugin_gstat" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } git2 = "0.20" \ No newline at end of file diff --git a/crates/nu_plugin_inc/Cargo.toml b/crates/nu_plugin_inc/Cargo.toml index 10c9ba248f..61fcd78388 100644 --- a/crates/nu_plugin_inc/Cargo.toml +++ b/crates/nu_plugin_inc/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_inc" edition = "2021" license = "MIT" name = "nu_plugin_inc" -version = "0.102.1" +version = "0.103.0" [lib] doctest = false @@ -16,7 +16,7 @@ name = "nu_plugin_inc" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } semver = "1.0" \ No newline at end of file diff --git a/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu b/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu index c0ef4cfe4f..82ea05f21f 100755 --- a/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu +++ b/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu @@ -6,7 +6,7 @@ # it also allows us to test the plugin interface with something manually implemented in a scripting # language without adding any extra dependencies to our tests. -const NUSHELL_VERSION = "0.102.1" +const NUSHELL_VERSION = "0.103.0" const PLUGIN_VERSION = "0.1.1" # bump if you change commands! def main [--stdio] { diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index d88c1c161b..09b1b31c3b 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu_plugin_polars" repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_polars" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,10 +17,10 @@ bench = false bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-path = { path = "../nu-path", version = "0.102.1" } -nu-utils = { path = "../nu-utils", version = "0.102.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.0" } # Potential dependencies for extras chrono = { workspace = true, features = ["std", "unstable-locales"], default-features = false } @@ -93,9 +93,9 @@ optional = false version = "0.46" [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.102.1" } -nu-engine = { path = "../nu-engine", version = "0.102.1" } -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-command = { path = "../nu-command", version = "0.102.1" } -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.102.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.0" } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-command = { path = "../nu-command", version = "0.103.0" } +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } tempfile.workspace = true diff --git a/crates/nu_plugin_python/nu_plugin_python_example.py b/crates/nu_plugin_python/nu_plugin_python_example.py index 2f3b9c3428..372d2ce431 100755 --- a/crates/nu_plugin_python/nu_plugin_python_example.py +++ b/crates/nu_plugin_python/nu_plugin_python_example.py @@ -27,7 +27,7 @@ import sys import json -NUSHELL_VERSION = "0.102.1" +NUSHELL_VERSION = "0.103.0" PLUGIN_VERSION = "0.1.1" # bump if you change commands! diff --git a/crates/nu_plugin_query/Cargo.toml b/crates/nu_plugin_query/Cargo.toml index c0e09f784e..bfba607aa6 100644 --- a/crates/nu_plugin_query/Cargo.toml +++ b/crates/nu_plugin_query/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_quer edition = "2021" license = "MIT" name = "nu_plugin_query" -version = "0.102.1" +version = "0.103.0" [lib] doctest = false @@ -16,8 +16,8 @@ name = "nu_plugin_query" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1" } +nu-plugin = { path = "../nu-plugin", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0" } gjson = "0.8" scraper = { default-features = false, version = "0.23" } diff --git a/crates/nu_plugin_stress_internals/Cargo.toml b/crates/nu_plugin_stress_internals/Cargo.toml index 8ca7198e7e..297ba7d6bf 100644 --- a/crates/nu_plugin_stress_internals/Cargo.toml +++ b/crates/nu_plugin_stress_internals/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_stre edition = "2021" license = "MIT" name = "nu_plugin_stress_internals" -version = "0.102.1" +version = "0.103.0" [[bin]] name = "nu_plugin_stress_internals" diff --git a/crates/nuon/Cargo.toml b/crates/nuon/Cargo.toml index a71ef74e36..e87e97a1d8 100644 --- a/crates/nuon/Cargo.toml +++ b/crates/nuon/Cargo.toml @@ -5,15 +5,15 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nuon" edition = "2021" license = "MIT" name = "nuon" -version = "0.102.1" +version = "0.103.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-parser = { path = "../nu-parser", version = "0.102.1" } -nu-protocol = { path = "../nu-protocol", version = "0.102.1", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.102.1", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.102.1", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } [dev-dependencies] chrono = { workspace = true } From 2c7ab6e898c4d6a6878d589a704001b870a90b0f Mon Sep 17 00:00:00 2001 From: Yash Thakur <45539777+ysthakur@users.noreply.github.com> Date: Wed, 19 Mar 2025 00:12:01 -0400 Subject: [PATCH 34/59] Bump to 0.103.1 dev version (#15347) # Description Marks development or hotfix --- Cargo.lock | 74 +++++++++---------- Cargo.toml | 40 +++++----- crates/nu-cli/Cargo.toml | 26 +++---- crates/nu-cmd-base/Cargo.toml | 10 +-- crates/nu-cmd-extra/Cargo.toml | 22 +++--- crates/nu-cmd-lang/Cargo.toml | 10 +-- crates/nu-cmd-plugin/Cargo.toml | 10 +-- crates/nu-color-config/Cargo.toml | 10 +-- crates/nu-command/Cargo.toml | 34 ++++----- crates/nu-derive-value/Cargo.toml | 2 +- crates/nu-engine/Cargo.toml | 10 +-- crates/nu-explore/Cargo.toml | 20 ++--- crates/nu-glob/Cargo.toml | 4 +- crates/nu-json/Cargo.toml | 6 +- crates/nu-lsp/Cargo.toml | 20 ++--- crates/nu-parser/Cargo.toml | 12 +-- crates/nu-path/Cargo.toml | 2 +- crates/nu-plugin-core/Cargo.toml | 6 +- crates/nu-plugin-engine/Cargo.toml | 14 ++-- crates/nu-plugin-protocol/Cargo.toml | 6 +- crates/nu-plugin-test-support/Cargo.toml | 18 ++--- crates/nu-plugin/Cargo.toml | 12 +-- crates/nu-pretty-hex/Cargo.toml | 2 +- crates/nu-protocol/Cargo.toml | 14 ++-- crates/nu-std/Cargo.toml | 8 +- crates/nu-system/Cargo.toml | 2 +- crates/nu-table/Cargo.toml | 12 +-- crates/nu-term-grid/Cargo.toml | 4 +- crates/nu-test-support/Cargo.toml | 8 +- crates/nu-utils/Cargo.toml | 2 +- .../src/default_files/default_config.nu | 2 +- .../nu-utils/src/default_files/default_env.nu | 2 +- .../nu-utils/src/default_files/doc_config.nu | 2 +- crates/nu-utils/src/default_files/doc_env.nu | 2 +- .../src/default_files/scaffold_config.nu | 2 +- .../src/default_files/scaffold_env.nu | 2 +- crates/nu_plugin_custom_values/Cargo.toml | 6 +- crates/nu_plugin_example/Cargo.toml | 10 +-- crates/nu_plugin_formats/Cargo.toml | 8 +- crates/nu_plugin_gstat/Cargo.toml | 6 +- crates/nu_plugin_inc/Cargo.toml | 6 +- .../nu_plugin_nu_example.nu | 2 +- crates/nu_plugin_polars/Cargo.toml | 20 ++--- .../nu_plugin_python_example.py | 2 +- crates/nu_plugin_query/Cargo.toml | 6 +- crates/nu_plugin_stress_internals/Cargo.toml | 2 +- crates/nuon/Cargo.toml | 10 +-- 47 files changed, 255 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76a98fc073..47ccd53a6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "nu" -version = "0.103.0" +version = "0.103.1" dependencies = [ "assert_cmd", "crossterm", @@ -3501,7 +3501,7 @@ dependencies = [ [[package]] name = "nu-cli" -version = "0.103.0" +version = "0.103.1" dependencies = [ "chrono", "crossterm", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "nu-cmd-base" -version = "0.103.0" +version = "0.103.1" dependencies = [ "indexmap", "miette", @@ -3549,7 +3549,7 @@ dependencies = [ [[package]] name = "nu-cmd-extra" -version = "0.103.0" +version = "0.103.1" dependencies = [ "fancy-regex", "heck", @@ -3575,7 +3575,7 @@ dependencies = [ [[package]] name = "nu-cmd-lang" -version = "0.103.0" +version = "0.103.1" dependencies = [ "itertools 0.13.0", "nu-engine", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "nu-cmd-plugin" -version = "0.103.0" +version = "0.103.1" dependencies = [ "itertools 0.13.0", "nu-engine", @@ -3600,7 +3600,7 @@ dependencies = [ [[package]] name = "nu-color-config" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-ansi-term", "nu-engine", @@ -3612,7 +3612,7 @@ dependencies = [ [[package]] name = "nu-command" -version = "0.103.0" +version = "0.103.1" dependencies = [ "alphanumeric-sort", "base64 0.22.1", @@ -3725,7 +3725,7 @@ dependencies = [ [[package]] name = "nu-derive-value" -version = "0.103.0" +version = "0.103.1" dependencies = [ "heck", "proc-macro-error2", @@ -3736,7 +3736,7 @@ dependencies = [ [[package]] name = "nu-engine" -version = "0.103.0" +version = "0.103.1" dependencies = [ "log", "nu-glob", @@ -3747,7 +3747,7 @@ dependencies = [ [[package]] name = "nu-explore" -version = "0.103.0" +version = "0.103.1" dependencies = [ "ansi-str", "anyhow", @@ -3771,7 +3771,7 @@ dependencies = [ [[package]] name = "nu-glob" -version = "0.103.0" +version = "0.103.1" dependencies = [ "doc-comment", "nu-protocol", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "nu-json" -version = "0.103.0" +version = "0.103.1" dependencies = [ "fancy-regex", "linked-hash-map", @@ -3792,7 +3792,7 @@ dependencies = [ [[package]] name = "nu-lsp" -version = "0.103.0" +version = "0.103.1" dependencies = [ "assert-json-diff", "crossbeam-channel", @@ -3817,7 +3817,7 @@ dependencies = [ [[package]] name = "nu-parser" -version = "0.103.0" +version = "0.103.1" dependencies = [ "bytesize", "chrono", @@ -3834,7 +3834,7 @@ dependencies = [ [[package]] name = "nu-path" -version = "0.103.0" +version = "0.103.1" dependencies = [ "dirs", "omnipath", @@ -3844,7 +3844,7 @@ dependencies = [ [[package]] name = "nu-plugin" -version = "0.103.0" +version = "0.103.1" dependencies = [ "log", "nix 0.29.0", @@ -3860,7 +3860,7 @@ dependencies = [ [[package]] name = "nu-plugin-core" -version = "0.103.0" +version = "0.103.1" dependencies = [ "interprocess", "log", @@ -3874,7 +3874,7 @@ dependencies = [ [[package]] name = "nu-plugin-engine" -version = "0.103.0" +version = "0.103.1" dependencies = [ "log", "nu-engine", @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "nu-plugin-protocol" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-protocol", "nu-utils", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "nu-plugin-test-support" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-ansi-term", "nu-cmd-lang", @@ -3920,7 +3920,7 @@ dependencies = [ [[package]] name = "nu-pretty-hex" -version = "0.103.0" +version = "0.103.1" dependencies = [ "heapless", "nu-ansi-term", @@ -3929,7 +3929,7 @@ dependencies = [ [[package]] name = "nu-protocol" -version = "0.103.0" +version = "0.103.1" dependencies = [ "brotli", "bytes", @@ -3968,7 +3968,7 @@ dependencies = [ [[package]] name = "nu-std" -version = "0.103.0" +version = "0.103.1" dependencies = [ "log", "miette", @@ -3979,7 +3979,7 @@ dependencies = [ [[package]] name = "nu-system" -version = "0.103.0" +version = "0.103.1" dependencies = [ "chrono", "itertools 0.13.0", @@ -3997,7 +3997,7 @@ dependencies = [ [[package]] name = "nu-table" -version = "0.103.0" +version = "0.103.1" dependencies = [ "fancy-regex", "nu-ansi-term", @@ -4010,7 +4010,7 @@ dependencies = [ [[package]] name = "nu-term-grid" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-utils", "unicode-width 0.2.0", @@ -4018,7 +4018,7 @@ dependencies = [ [[package]] name = "nu-test-support" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-glob", "nu-path", @@ -4030,7 +4030,7 @@ dependencies = [ [[package]] name = "nu-utils" -version = "0.103.0" +version = "0.103.1" dependencies = [ "crossterm", "crossterm_winapi", @@ -4059,7 +4059,7 @@ dependencies = [ [[package]] name = "nu_plugin_example" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-cmd-lang", "nu-plugin", @@ -4069,7 +4069,7 @@ dependencies = [ [[package]] name = "nu_plugin_formats" -version = "0.103.0" +version = "0.103.1" dependencies = [ "chrono", "eml-parser", @@ -4084,7 +4084,7 @@ dependencies = [ [[package]] name = "nu_plugin_gstat" -version = "0.103.0" +version = "0.103.1" dependencies = [ "git2", "nu-plugin", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "nu_plugin_inc" -version = "0.103.0" +version = "0.103.1" dependencies = [ "nu-plugin", "nu-protocol", @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "nu_plugin_polars" -version = "0.103.0" +version = "0.103.1" dependencies = [ "aws-config", "aws-credential-types", @@ -4141,7 +4141,7 @@ dependencies = [ [[package]] name = "nu_plugin_query" -version = "0.103.0" +version = "0.103.1" dependencies = [ "gjson", "nu-plugin", @@ -4156,7 +4156,7 @@ dependencies = [ [[package]] name = "nu_plugin_stress_internals" -version = "0.103.0" +version = "0.103.1" dependencies = [ "interprocess", "serde", @@ -4280,7 +4280,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nuon" -version = "0.103.0" +version = "0.103.1" dependencies = [ "chrono", "nu-engine", diff --git a/Cargo.toml b/Cargo.toml index 64786bdaba..545cb6f1cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" name = "nu" repository = "https://github.com/nushell/nushell" rust-version = "1.83.0" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -197,22 +197,22 @@ unchecked_duration_subtraction = "warn" workspace = true [dependencies] -nu-cli = { path = "./crates/nu-cli", version = "0.103.0" } -nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.103.0" } -nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.103.0" } -nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.103.0", optional = true } -nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.103.0" } -nu-command = { path = "./crates/nu-command", version = "0.103.0" } -nu-engine = { path = "./crates/nu-engine", version = "0.103.0" } -nu-explore = { path = "./crates/nu-explore", version = "0.103.0" } -nu-lsp = { path = "./crates/nu-lsp/", version = "0.103.0" } -nu-parser = { path = "./crates/nu-parser", version = "0.103.0" } -nu-path = { path = "./crates/nu-path", version = "0.103.0" } -nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.103.0" } -nu-protocol = { path = "./crates/nu-protocol", version = "0.103.0" } -nu-std = { path = "./crates/nu-std", version = "0.103.0" } -nu-system = { path = "./crates/nu-system", version = "0.103.0" } -nu-utils = { path = "./crates/nu-utils", version = "0.103.0" } +nu-cli = { path = "./crates/nu-cli", version = "0.103.1" } +nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.103.1" } +nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.103.1" } +nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.103.1", optional = true } +nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.103.1" } +nu-command = { path = "./crates/nu-command", version = "0.103.1" } +nu-engine = { path = "./crates/nu-engine", version = "0.103.1" } +nu-explore = { path = "./crates/nu-explore", version = "0.103.1" } +nu-lsp = { path = "./crates/nu-lsp/", version = "0.103.1" } +nu-parser = { path = "./crates/nu-parser", version = "0.103.1" } +nu-path = { path = "./crates/nu-path", version = "0.103.1" } +nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.103.1" } +nu-protocol = { path = "./crates/nu-protocol", version = "0.103.1" } +nu-std = { path = "./crates/nu-std", version = "0.103.1" } +nu-system = { path = "./crates/nu-system", version = "0.103.1" } +nu-utils = { path = "./crates/nu-utils", version = "0.103.1" } reedline = { workspace = true, features = ["bashisms", "sqlite"] } crossterm = { workspace = true } @@ -241,9 +241,9 @@ nix = { workspace = true, default-features = false, features = [ ] } [dev-dependencies] -nu-test-support = { path = "./crates/nu-test-support", version = "0.103.0" } -nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.103.0" } -nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.103.0" } +nu-test-support = { path = "./crates/nu-test-support", version = "0.103.1" } +nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.103.1" } +nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.103.1" } assert_cmd = "2.0" dirs = { workspace = true } tango-bench = "0.6" diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 41d2ef25e5..f3bfb0f91c 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -5,28 +5,28 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli" edition = "2021" license = "MIT" name = "nu-cli" -version = "0.103.0" +version = "0.103.1" [lib] bench = false [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } -nu-command = { path = "../nu-command", version = "0.103.0" } -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } +nu-command = { path = "../nu-command", version = "0.103.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } rstest = { workspace = true, default-features = false } tempfile = { workspace = true } [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["os"] } -nu-glob = { path = "../nu-glob", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0", optional = true } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["os"] } -nu-utils = { path = "../nu-utils", version = "0.103.0" } -nu-color-config = { path = "../nu-color-config", version = "0.103.0" } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1", features = ["os"] } +nu-glob = { path = "../nu-glob", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.1", optional = true } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["os"] } +nu-utils = { path = "../nu-utils", version = "0.103.1" } +nu-color-config = { path = "../nu-color-config", version = "0.103.1" } nu-ansi-term = { workspace = true } reedline = { workspace = true, features = ["bashisms", "sqlite"] } diff --git a/crates/nu-cmd-base/Cargo.toml b/crates/nu-cmd-base/Cargo.toml index 1af9be44d3..6b771ee667 100644 --- a/crates/nu-cmd-base/Cargo.toml +++ b/crates/nu-cmd-base/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-base" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,10 +13,10 @@ version = "0.103.0" workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } indexmap = { workspace = true } miette = { workspace = true } diff --git a/crates/nu-cmd-extra/Cargo.toml b/crates/nu-cmd-extra/Cargo.toml index 83aab0d165..c68724e429 100644 --- a/crates/nu-cmd-extra/Cargo.toml +++ b/crates/nu-cmd-extra/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-extra" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,13 +16,13 @@ bench = false workspace = true [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-json = { version = "0.103.0", path = "../nu-json" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-pretty-hex = { version = "0.103.0", path = "../nu-pretty-hex" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-json = { version = "0.103.1", path = "../nu-json" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-pretty-hex = { version = "0.103.1", path = "../nu-pretty-hex" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } # Potential dependencies for extras heck = { workspace = true } @@ -37,6 +37,6 @@ itertools = { workspace = true } mime = { workspace = true } [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } -nu-command = { path = "../nu-command", version = "0.103.0" } -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } +nu-command = { path = "../nu-command", version = "0.103.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } diff --git a/crates/nu-cmd-lang/Cargo.toml b/crates/nu-cmd-lang/Cargo.toml index 76691e6180..62beafd701 100644 --- a/crates/nu-cmd-lang/Cargo.toml +++ b/crates/nu-cmd-lang/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang" edition = "2021" license = "MIT" name = "nu-cmd-lang" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -15,10 +15,10 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } itertools = { workspace = true } shadow-rs = { version = "0.38", default-features = false } diff --git a/crates/nu-cmd-plugin/Cargo.toml b/crates/nu-cmd-plugin/Cargo.toml index 265721cdcf..4a0360ee34 100644 --- a/crates/nu-cmd-plugin/Cargo.toml +++ b/crates/nu-cmd-plugin/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-cmd-plugin" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,10 +13,10 @@ version = "0.103.0" workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.1" } itertools = { workspace = true } diff --git a/crates/nu-color-config/Cargo.toml b/crates/nu-color-config/Cargo.toml index 060fe49a63..f42585ceb7 100644 --- a/crates/nu-color-config/Cargo.toml +++ b/crates/nu-color-config/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi edition = "2021" license = "MIT" name = "nu-color-config" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,12 +14,12 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-json = { path = "../nu-json", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-json = { path = "../nu-json", version = "0.103.1" } nu-ansi-term = { workspace = true } serde = { workspace = true, features = ["derive"] } [dev-dependencies] -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } \ No newline at end of file +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } \ No newline at end of file diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 77169ab661..babdce20de 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-command" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,21 +16,21 @@ bench = false workspace = true [dependencies] -nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.0" } -nu-color-config = { path = "../nu-color-config", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-glob = { path = "../nu-glob", version = "0.103.0" } -nu-json = { path = "../nu-json", version = "0.103.0" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-system = { path = "../nu-system", version = "0.103.0" } -nu-table = { path = "../nu-table", version = "0.103.0" } -nu-term-grid = { path = "../nu-term-grid", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-cmd-base = { path = "../nu-cmd-base", version = "0.103.1" } +nu-color-config = { path = "../nu-color-config", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-glob = { path = "../nu-glob", version = "0.103.1" } +nu-json = { path = "../nu-json", version = "0.103.1" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-system = { path = "../nu-system", version = "0.103.1" } +nu-table = { path = "../nu-table", version = "0.103.1" } +nu-term-grid = { path = "../nu-term-grid", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } nu-ansi-term = { workspace = true } -nuon = { path = "../nuon", version = "0.103.0" } +nuon = { path = "../nuon", version = "0.103.1" } alphanumeric-sort = { workspace = true } base64 = { workspace = true } @@ -209,8 +209,8 @@ sqlite = ["rusqlite"] trash-support = ["trash"] [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } dirs = { workspace = true } mockito = { workspace = true, default-features = false } diff --git a/crates/nu-derive-value/Cargo.toml b/crates/nu-derive-value/Cargo.toml index f4e032844f..df34048ef6 100644 --- a/crates/nu-derive-value/Cargo.toml +++ b/crates/nu-derive-value/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-derive-value" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-derive-value" -version = "0.103.0" +version = "0.103.1" [lib] proc-macro = true diff --git a/crates/nu-engine/Cargo.toml b/crates/nu-engine/Cargo.toml index 1c40cefeaa..f351a11654 100644 --- a/crates/nu-engine/Cargo.toml +++ b/crates/nu-engine/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine" edition = "2021" license = "MIT" name = "nu-engine" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,10 +14,10 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-glob = { path = "../nu-glob", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-glob = { path = "../nu-glob", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } log = { workspace = true } [features] diff --git a/crates/nu-explore/Cargo.toml b/crates/nu-explore/Cargo.toml index 3f64922e22..a5a14a0e1f 100644 --- a/crates/nu-explore/Cargo.toml +++ b/crates/nu-explore/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-explore" edition = "2021" license = "MIT" name = "nu-explore" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,16 +14,16 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-color-config = { path = "../nu-color-config", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0" } -nu-table = { path = "../nu-table", version = "0.103.0" } -nu-json = { path = "../nu-json", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-color-config = { path = "../nu-color-config", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1" } +nu-table = { path = "../nu-table", version = "0.103.1" } +nu-json = { path = "../nu-json", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1" } nu-ansi-term = { workspace = true } -nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.0" } +nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.103.1" } anyhow = { workspace = true } log = { workspace = true } diff --git a/crates/nu-glob/Cargo.toml b/crates/nu-glob/Cargo.toml index 1d4f6da5da..b1f4835429 100644 --- a/crates/nu-glob/Cargo.toml +++ b/crates/nu-glob/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu-glob" -version = "0.103.0" +version = "0.103.1" authors = ["The Nushell Project Developers", "The Rust Project Developers"] license = "MIT/Apache-2.0" description = """ @@ -14,7 +14,7 @@ categories = ["filesystem"] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } [dev-dependencies] doc-comment = "0.3" diff --git a/crates/nu-json/Cargo.toml b/crates/nu-json/Cargo.toml index d6beb7aa59..2b8ae829a1 100644 --- a/crates/nu-json/Cargo.toml +++ b/crates/nu-json/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-json" edition = "2021" license = "MIT" name = "nu-json" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -26,8 +26,8 @@ serde = { workspace = true } serde_json = { workspace = true } [dev-dependencies] -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } serde_json = "1.0" fancy-regex = "0.14.0" diff --git a/crates/nu-lsp/Cargo.toml b/crates/nu-lsp/Cargo.toml index a23d916f99..5f3fabbf19 100644 --- a/crates/nu-lsp/Cargo.toml +++ b/crates/nu-lsp/Cargo.toml @@ -3,16 +3,16 @@ authors = ["The Nushell Project Developers"] description = "Nushell's integrated LSP server" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-lsp" name = "nu-lsp" -version = "0.103.0" +version = "0.103.1" edition = "2021" license = "MIT" [dependencies] -nu-cli = { path = "../nu-cli", version = "0.103.0" } -nu-glob = { path = "../nu-glob", version = "0.103.0" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-cli = { path = "../nu-cli", version = "0.103.1" } +nu-glob = { path = "../nu-glob", version = "0.103.1" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1" } crossbeam-channel = { workspace = true } lsp-server = { workspace = true } @@ -25,10 +25,10 @@ serde_json = { workspace = true } url = { workspace = true } [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } -nu-command = { path = "../nu-command", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0" } -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } +nu-command = { path = "../nu-command", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } assert-json-diff = "2.0" diff --git a/crates/nu-parser/Cargo.toml b/crates/nu-parser/Cargo.toml index 924539bdb6..a1914b7561 100644 --- a/crates/nu-parser/Cargo.toml +++ b/crates/nu-parser/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-parser" edition = "2021" license = "MIT" name = "nu-parser" -version = "0.103.0" +version = "0.103.1" exclude = ["/fuzz"] [lib] @@ -15,11 +15,11 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } bytesize = { workspace = true } chrono = { default-features = false, features = ['std'], workspace = true } diff --git a/crates/nu-path/Cargo.toml b/crates/nu-path/Cargo.toml index c4a628e2d5..320629258e 100644 --- a/crates/nu-path/Cargo.toml +++ b/crates/nu-path/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-path" edition = "2021" license = "MIT" name = "nu-path" -version = "0.103.0" +version = "0.103.1" exclude = ["/fuzz"] [lib] diff --git a/crates/nu-plugin-core/Cargo.toml b/crates/nu-plugin-core/Cargo.toml index 404a350d8c..f220e648c4 100644 --- a/crates/nu-plugin-core/Cargo.toml +++ b/crates/nu-plugin-core/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-core edition = "2021" license = "MIT" name = "nu-plugin-core" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,8 +14,8 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0", default-features = false } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.1", default-features = false } rmp-serde = { workspace = true } serde = { workspace = true } diff --git a/crates/nu-plugin-engine/Cargo.toml b/crates/nu-plugin-engine/Cargo.toml index 42f2f80687..8b9eb17544 100644 --- a/crates/nu-plugin-engine/Cargo.toml +++ b/crates/nu-plugin-engine/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-engi edition = "2021" license = "MIT" name = "nu-plugin-engine" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,12 +14,12 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } -nu-system = { path = "../nu-system", version = "0.103.0" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } +nu-system = { path = "../nu-system", version = "0.103.1" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.1" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1" } serde = { workspace = true } log = { workspace = true } diff --git a/crates/nu-plugin-protocol/Cargo.toml b/crates/nu-plugin-protocol/Cargo.toml index 892877ae5d..a6c9e1ba0b 100644 --- a/crates/nu-plugin-protocol/Cargo.toml +++ b/crates/nu-plugin-protocol/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-prot edition = "2021" license = "MIT" name = "nu-plugin-protocol" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,8 +14,8 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } +nu-utils = { path = "../nu-utils", version = "0.103.1" } rmp-serde = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/nu-plugin-test-support/Cargo.toml b/crates/nu-plugin-test-support/Cargo.toml index 98b33bb8ce..0d0fa83851 100644 --- a/crates/nu-plugin-test-support/Cargo.toml +++ b/crates/nu-plugin-test-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nu-plugin-test-support" -version = "0.103.0" +version = "0.103.1" edition = "2021" license = "MIT" description = "Testing support for Nushell plugins" @@ -15,14 +15,14 @@ workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["plugin"] } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } -nu-parser = { path = "../nu-parser", version = "0.103.0", features = ["plugin"] } -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0" } -nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.0" } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.1", features = ["plugin"] } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } +nu-parser = { path = "../nu-parser", version = "0.103.1", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.1" } +nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.103.1" } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } nu-ansi-term = { workspace = true } similar = "2.7" diff --git a/crates/nu-plugin/Cargo.toml b/crates/nu-plugin/Cargo.toml index e5486133e5..6f81e9b3f0 100644 --- a/crates/nu-plugin/Cargo.toml +++ b/crates/nu-plugin/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin" edition = "2021" license = "MIT" name = "nu-plugin" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,11 +14,11 @@ bench = false workspace = true [dependencies] -nu-engine = { path = "../nu-engine", version = "0.103.0", features = ["plugin"] } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } -nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.0" } -nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-engine = { path = "../nu-engine", version = "0.103.1", features = ["plugin"] } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } +nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.103.1" } +nu-plugin-core = { path = "../nu-plugin-core", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1" } log = { workspace = true } thiserror = "2.0" diff --git a/crates/nu-pretty-hex/Cargo.toml b/crates/nu-pretty-hex/Cargo.toml index ac3f774b8d..8e0c2079f9 100644 --- a/crates/nu-pretty-hex/Cargo.toml +++ b/crates/nu-pretty-hex/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-pretty-hex" edition = "2021" license = "MIT" name = "nu-pretty-hex" -version = "0.103.0" +version = "0.103.1" [lib] doctest = false diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml index d1ef23d699..831741464a 100644 --- a/crates/nu-protocol/Cargo.toml +++ b/crates/nu-protocol/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-protocol" edition = "2021" license = "MIT" name = "nu-protocol" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,10 +16,10 @@ bench = false workspace = true [dependencies] -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-system = { path = "../nu-system", version = "0.103.0" } -nu-derive-value = { path = "../nu-derive-value", version = "0.103.0" } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-system = { path = "../nu-system", version = "0.103.1" } +nu-derive-value = { path = "../nu-derive-value", version = "0.103.1" } brotli = { workspace = true, optional = true } bytes = { workspace = true } @@ -66,8 +66,8 @@ plugin = [ [dev-dependencies] serde_json = { workspace = true } -nu-test-support = { path = "../nu-test-support", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-test-support = { path = "../nu-test-support", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1" } pretty_assertions = { workspace = true } rstest = { workspace = true } tempfile = { workspace = true } diff --git a/crates/nu-std/Cargo.toml b/crates/nu-std/Cargo.toml index 2d703263d8..8e2389ccca 100644 --- a/crates/nu-std/Cargo.toml +++ b/crates/nu-std/Cargo.toml @@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-std" edition = "2021" license = "MIT" name = "nu-std" -version = "0.103.0" +version = "0.103.1" [dependencies] -nu-parser = { version = "0.103.0", path = "../nu-parser" } -nu-protocol = { version = "0.103.0", path = "../nu-protocol", default-features = false } -nu-engine = { version = "0.103.0", path = "../nu-engine", default-features = false } +nu-parser = { version = "0.103.1", path = "../nu-parser" } +nu-protocol = { version = "0.103.1", path = "../nu-protocol", default-features = false } +nu-engine = { version = "0.103.1", path = "../nu-engine", default-features = false } miette = { workspace = true, features = ["fancy-no-backtrace"] } log = "0.4" diff --git a/crates/nu-system/Cargo.toml b/crates/nu-system/Cargo.toml index 2a8d48865d..ad29400e63 100644 --- a/crates/nu-system/Cargo.toml +++ b/crates/nu-system/Cargo.toml @@ -3,7 +3,7 @@ authors = ["The Nushell Project Developers", "procs creators"] description = "Nushell system querying" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-system" name = "nu-system" -version = "0.103.0" +version = "0.103.1" edition = "2021" license = "MIT" diff --git a/crates/nu-table/Cargo.toml b/crates/nu-table/Cargo.toml index 889a5d4d6e..82c6c8cd34 100644 --- a/crates/nu-table/Cargo.toml +++ b/crates/nu-table/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-table" edition = "2021" license = "MIT" name = "nu-table" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,13 +14,13 @@ bench = false workspace = true [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-color-config = { path = "../nu-color-config", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-color-config = { path = "../nu-color-config", version = "0.103.1" } nu-ansi-term = { workspace = true } fancy-regex = { workspace = true } tabled = { workspace = true, features = ["ansi"], default-features = false } [dev-dependencies] -# nu-test-support = { path="../nu-test-support", version = "0.103.0" } \ No newline at end of file +# nu-test-support = { path="../nu-test-support", version = "0.103.1" } \ No newline at end of file diff --git a/crates/nu-term-grid/Cargo.toml b/crates/nu-term-grid/Cargo.toml index 1918e91235..b7676db1e7 100644 --- a/crates/nu-term-grid/Cargo.toml +++ b/crates/nu-term-grid/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-term-grid" edition = "2021" license = "MIT" name = "nu-term-grid" -version = "0.103.0" +version = "0.103.1" [lib] bench = false @@ -14,6 +14,6 @@ bench = false workspace = true [dependencies] -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } unicode-width = { workspace = true } \ No newline at end of file diff --git a/crates/nu-test-support/Cargo.toml b/crates/nu-test-support/Cargo.toml index a78e4dca61..bc3393b8d9 100644 --- a/crates/nu-test-support/Cargo.toml +++ b/crates/nu-test-support/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-test-suppor edition = "2021" license = "MIT" name = "nu-test-support" -version = "0.103.0" +version = "0.103.1" [lib] doctest = false @@ -15,9 +15,9 @@ bench = false workspace = true [dependencies] -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-glob = { path = "../nu-glob", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-glob = { path = "../nu-glob", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1" } num-format = { workspace = true } which = { workspace = true } diff --git a/crates/nu-utils/Cargo.toml b/crates/nu-utils/Cargo.toml index d9a88bcea5..95a26ab2fb 100644 --- a/crates/nu-utils/Cargo.toml +++ b/crates/nu-utils/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu-utils" repository = "https://github.com/nushell/nushell/tree/main/crates/nu-utils" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [[bin]] diff --git a/crates/nu-utils/src/default_files/default_config.nu b/crates/nu-utils/src/default_files/default_config.nu index 6d0fd3cb15..b7cc5675fc 100644 --- a/crates/nu-utils/src/default_files/default_config.nu +++ b/crates/nu-utils/src/default_files/default_config.nu @@ -1,6 +1,6 @@ # Nushell Config File # -# version = "0.103.0" +# version = "0.103.1" $env.config.color_config = { separator: white leading_trailing_space_bg: { attr: n } diff --git a/crates/nu-utils/src/default_files/default_env.nu b/crates/nu-utils/src/default_files/default_env.nu index 7b18561179..1d4c302f73 100644 --- a/crates/nu-utils/src/default_files/default_env.nu +++ b/crates/nu-utils/src/default_files/default_env.nu @@ -1,7 +1,7 @@ # Default Nushell Environment Config File # These "sensible defaults" are set before the user's `env.nu` is loaded # -# version = "0.103.0" +# version = "0.103.1" $env.PROMPT_COMMAND = {|| let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) { diff --git a/crates/nu-utils/src/default_files/doc_config.nu b/crates/nu-utils/src/default_files/doc_config.nu index d2d3bc5708..33296bc9c2 100644 --- a/crates/nu-utils/src/default_files/doc_config.nu +++ b/crates/nu-utils/src/default_files/doc_config.nu @@ -3,7 +3,7 @@ # Warning: This file is intended for documentation purposes only and # is not intended to be used as an actual configuration file as-is. # -# version = "0.103.0" +# version = "0.103.1" # # A `config.nu` file is used to override default Nushell settings, # define (or import) custom commands, or run any other startup tasks. diff --git a/crates/nu-utils/src/default_files/doc_env.nu b/crates/nu-utils/src/default_files/doc_env.nu index 6d639146e1..87e2b54838 100644 --- a/crates/nu-utils/src/default_files/doc_env.nu +++ b/crates/nu-utils/src/default_files/doc_env.nu @@ -1,6 +1,6 @@ # Nushell Environment Config File Documentation # -# version = "0.103.0" +# version = "0.103.1" # # Previously, environment variables were typically configured in `env.nu`. # In general, most configuration can and should be performed in `config.nu` diff --git a/crates/nu-utils/src/default_files/scaffold_config.nu b/crates/nu-utils/src/default_files/scaffold_config.nu index ca44a41929..6f9688c18e 100644 --- a/crates/nu-utils/src/default_files/scaffold_config.nu +++ b/crates/nu-utils/src/default_files/scaffold_config.nu @@ -1,7 +1,7 @@ # config.nu # # Installed by: -# version = "0.103.0" +# version = "0.103.1" # # This file is used to override default Nushell settings, define # (or import) custom commands, or run any other startup tasks. diff --git a/crates/nu-utils/src/default_files/scaffold_env.nu b/crates/nu-utils/src/default_files/scaffold_env.nu index 2a6217eb6b..f0588715a0 100644 --- a/crates/nu-utils/src/default_files/scaffold_env.nu +++ b/crates/nu-utils/src/default_files/scaffold_env.nu @@ -1,7 +1,7 @@ # env.nu # # Installed by: -# version = "0.103.0" +# version = "0.103.1" # # Previously, environment variables were typically configured in `env.nu`. # In general, most configuration can and should be performed in `config.nu` diff --git a/crates/nu_plugin_custom_values/Cargo.toml b/crates/nu_plugin_custom_values/Cargo.toml index fd05381f79..eaf6bd105f 100644 --- a/crates/nu_plugin_custom_values/Cargo.toml +++ b/crates/nu_plugin_custom_values/Cargo.toml @@ -10,10 +10,10 @@ name = "nu_plugin_custom_values" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0", features = [] } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.1", features = [] } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } serde = { workspace = true } typetag = "0.2" [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.1" } \ No newline at end of file diff --git a/crates/nu_plugin_example/Cargo.toml b/crates/nu_plugin_example/Cargo.toml index d685a881c9..7b73f1cf82 100644 --- a/crates/nu_plugin_example/Cargo.toml +++ b/crates/nu_plugin_example/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_exam edition = "2021" license = "MIT" name = "nu_plugin_example" -version = "0.103.0" +version = "0.103.1" [[bin]] name = "nu_plugin_example" @@ -15,9 +15,9 @@ bench = false bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.1" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } \ No newline at end of file diff --git a/crates/nu_plugin_formats/Cargo.toml b/crates/nu_plugin_formats/Cargo.toml index 2cff18c69c..c0e3d23acb 100644 --- a/crates/nu_plugin_formats/Cargo.toml +++ b/crates/nu_plugin_formats/Cargo.toml @@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_form edition = "2021" license = "MIT" name = "nu_plugin_formats" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } indexmap = { workspace = true } eml-parser = "0.1" @@ -20,4 +20,4 @@ plist = "1.7" chrono = "0.4" [dev-dependencies] -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } \ No newline at end of file +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.1" } \ No newline at end of file diff --git a/crates/nu_plugin_gstat/Cargo.toml b/crates/nu_plugin_gstat/Cargo.toml index 82c8268b6c..ac8476bee5 100644 --- a/crates/nu_plugin_gstat/Cargo.toml +++ b/crates/nu_plugin_gstat/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_gsta edition = "2021" license = "MIT" name = "nu_plugin_gstat" -version = "0.103.0" +version = "0.103.1" [lib] doctest = false @@ -16,7 +16,7 @@ name = "nu_plugin_gstat" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } git2 = "0.20" \ No newline at end of file diff --git a/crates/nu_plugin_inc/Cargo.toml b/crates/nu_plugin_inc/Cargo.toml index 61fcd78388..c358fc3ce5 100644 --- a/crates/nu_plugin_inc/Cargo.toml +++ b/crates/nu_plugin_inc/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_inc" edition = "2021" license = "MIT" name = "nu_plugin_inc" -version = "0.103.0" +version = "0.103.1" [lib] doctest = false @@ -16,7 +16,7 @@ name = "nu_plugin_inc" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", features = ["plugin"] } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", features = ["plugin"] } semver = "1.0" \ No newline at end of file diff --git a/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu b/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu index 82ea05f21f..9c936007b6 100755 --- a/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu +++ b/crates/nu_plugin_nu_example/nu_plugin_nu_example.nu @@ -6,7 +6,7 @@ # it also allows us to test the plugin interface with something manually implemented in a scripting # language without adding any extra dependencies to our tests. -const NUSHELL_VERSION = "0.103.0" +const NUSHELL_VERSION = "0.103.1" const PLUGIN_VERSION = "0.1.1" # bump if you change commands! def main [--stdio] { diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index 09b1b31c3b..1989a10bc3 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "MIT" name = "nu_plugin_polars" repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_polars" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,10 +17,10 @@ bench = false bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-path = { path = "../nu-path", version = "0.103.0" } -nu-utils = { path = "../nu-utils", version = "0.103.0" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-path = { path = "../nu-path", version = "0.103.1" } +nu-utils = { path = "../nu-utils", version = "0.103.1" } # Potential dependencies for extras chrono = { workspace = true, features = ["std", "unstable-locales"], default-features = false } @@ -93,9 +93,9 @@ optional = false version = "0.46" [dev-dependencies] -nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.0" } -nu-engine = { path = "../nu-engine", version = "0.103.0" } -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-command = { path = "../nu-command", version = "0.103.0" } -nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.0" } +nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.103.1" } +nu-engine = { path = "../nu-engine", version = "0.103.1" } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-command = { path = "../nu-command", version = "0.103.1" } +nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.103.1" } tempfile.workspace = true diff --git a/crates/nu_plugin_python/nu_plugin_python_example.py b/crates/nu_plugin_python/nu_plugin_python_example.py index 372d2ce431..29348db1d3 100755 --- a/crates/nu_plugin_python/nu_plugin_python_example.py +++ b/crates/nu_plugin_python/nu_plugin_python_example.py @@ -27,7 +27,7 @@ import sys import json -NUSHELL_VERSION = "0.103.0" +NUSHELL_VERSION = "0.103.1" PLUGIN_VERSION = "0.1.1" # bump if you change commands! diff --git a/crates/nu_plugin_query/Cargo.toml b/crates/nu_plugin_query/Cargo.toml index bfba607aa6..4f625253e4 100644 --- a/crates/nu_plugin_query/Cargo.toml +++ b/crates/nu_plugin_query/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_quer edition = "2021" license = "MIT" name = "nu_plugin_query" -version = "0.103.0" +version = "0.103.1" [lib] doctest = false @@ -16,8 +16,8 @@ name = "nu_plugin_query" bench = false [dependencies] -nu-plugin = { path = "../nu-plugin", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0" } +nu-plugin = { path = "../nu-plugin", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1" } gjson = "0.8" scraper = { default-features = false, version = "0.23" } diff --git a/crates/nu_plugin_stress_internals/Cargo.toml b/crates/nu_plugin_stress_internals/Cargo.toml index 297ba7d6bf..f264d875e2 100644 --- a/crates/nu_plugin_stress_internals/Cargo.toml +++ b/crates/nu_plugin_stress_internals/Cargo.toml @@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_stre edition = "2021" license = "MIT" name = "nu_plugin_stress_internals" -version = "0.103.0" +version = "0.103.1" [[bin]] name = "nu_plugin_stress_internals" diff --git a/crates/nuon/Cargo.toml b/crates/nuon/Cargo.toml index e87e97a1d8..66ddfba101 100644 --- a/crates/nuon/Cargo.toml +++ b/crates/nuon/Cargo.toml @@ -5,15 +5,15 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nuon" edition = "2021" license = "MIT" name = "nuon" -version = "0.103.0" +version = "0.103.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nu-parser = { path = "../nu-parser", version = "0.103.0" } -nu-protocol = { path = "../nu-protocol", version = "0.103.0", default-features = false } -nu-engine = { path = "../nu-engine", version = "0.103.0", default-features = false } -nu-utils = { path = "../nu-utils", version = "0.103.0", default-features = false } +nu-parser = { path = "../nu-parser", version = "0.103.1" } +nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } +nu-engine = { path = "../nu-engine", version = "0.103.1", default-features = false } +nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } [dev-dependencies] chrono = { workspace = true } From 69d1c8e948f8a3e69bdaeefa0e44c4a41e4abf86 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Wed, 19 Mar 2025 22:59:06 -0400 Subject: [PATCH 35/59] Add compile-time assertion of `Value`'s size (#15362) # Description Adds an assertion of `Value`'s size, similar to `Instruction` and `Expr`. --- crates/nu-protocol/src/value/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index fb189daca8..428031c48f 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -168,6 +168,11 @@ pub enum Value { }, } +// This is to document/enforce the size of `Value` in bytes. +// We should try to avoid increasing the size of `Value`, +// and PRs that do so will have to change the number below so that it's noted in review. +const _: () = assert!(std::mem::size_of::() <= 48); + impl Clone for Value { fn clone(&self) -> Self { match self { From 2c1d261ccaea3cee0b6548e837c3dc43003d8cdc Mon Sep 17 00:00:00 2001 From: zc he Date: Thu, 20 Mar 2025 19:53:06 +0800 Subject: [PATCH 36/59] fix(explore): do not create extra layer for empty entries (#15367) Fixes #15329 # Description Stops entering empty list/record with the following message: image # User-Facing Changes # Tests + Formatting +5, all vibe coded. # After Submitting --- crates/nu-explore/src/views/record/mod.rs | 122 +++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/crates/nu-explore/src/views/record/mod.rs b/crates/nu-explore/src/views/record/mod.rs index 3e7d00615d..1afc4c8dc6 100644 --- a/crates/nu-explore/src/views/record/mod.rs +++ b/crates/nu-explore/src/views/record/mod.rs @@ -457,7 +457,9 @@ impl CursorMoveHandler for RecordView { fn create_layer(value: Value) -> Result { let (columns, values) = collect_input(value)?; - + if columns.is_empty() { + return Err(anyhow::anyhow!("Nothing to explore in empty collections!")); + } Ok(RecordLayer::new(columns, values)) } @@ -684,3 +686,121 @@ fn strip_string(text: &str) -> String { .map_err(|_| ()) .unwrap_or_else(|_| text.to_owned()) } + +#[cfg(test)] +mod tests { + use super::*; + use nu_protocol::{span::Span, Value}; + + // Helper to create a simple test Value::Record + fn create_test_record() -> Value { + let mut record = Record::new(); + record.insert( + "name".to_string(), + Value::string("sample", Span::test_data()), + ); + record.insert("value".to_string(), Value::int(42, Span::test_data())); + Value::record(record, Span::test_data()) + } + + // Helper to create a simple test Value::List + fn create_test_list() -> Value { + let items = vec![ + Value::string("item1", Span::test_data()), + Value::string("item2", Span::test_data()), + ]; + Value::list(items, Span::test_data()) + } + + #[test] + fn test_create_layer_empty_collection() { + // Test with empty record + let empty_record = Value::record(Record::new(), Span::test_data()); + let result = create_layer(empty_record); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + "Nothing to explore in empty collections!" + ); + + // Test with empty list + let empty_list = Value::list(vec![], Span::test_data()); + let result = create_layer(empty_list); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + "Nothing to explore in empty collections!" + ); + } + + #[test] + fn test_create_layer_valid_record() { + let record = create_test_record(); + let result = create_layer(record); + assert!(result.is_ok()); + + let layer = result.unwrap(); + assert_eq!(layer.column_names, vec!["name", "value"]); + assert_eq!(layer.record_values.len(), 1); + assert_eq!(layer.record_values[0].len(), 2); + } + + #[test] + fn test_create_layer_valid_list() { + let list = create_test_list(); + let result = create_layer(list); + assert!(result.is_ok()); + + let layer = result.unwrap(); + assert_eq!(layer.column_names, vec![""]); + assert_eq!(layer.record_values.len(), 2); + assert_eq!(layer.record_values[0].len(), 1); + } + + #[test] + fn test_transpose_table() { + // Create a simple 2x3 table + let mut layer = RecordLayer::new( + vec!["col1".to_string(), "col2".to_string(), "col3".to_string()], + vec![ + vec![ + Value::string("r1c1", Span::test_data()), + Value::string("r1c2", Span::test_data()), + Value::string("r1c3", Span::test_data()), + ], + vec![ + Value::string("r2c1", Span::test_data()), + Value::string("r2c2", Span::test_data()), + Value::string("r2c3", Span::test_data()), + ], + ], + ); + + // Before transpose + assert_eq!(layer.count_rows(), 2); + assert_eq!(layer.count_columns(), 3); + assert!(!layer.was_transposed); + + // After transpose + transpose_table(&mut layer); + assert_eq!(layer.count_rows(), 3); + assert_eq!(layer.count_columns(), 3); // Now includes header row + assert!(layer.was_transposed); + + // After transpose back + transpose_table(&mut layer); + assert_eq!(layer.count_rows(), 2); + assert_eq!(layer.count_columns(), 3); + assert!(!layer.was_transposed); + } + + #[test] + fn test_estimate_page_size() { + // Test with header + let area = Rect::new(0, 0, 80, 24); + assert_eq!(estimate_page_size(area, true), 18); // 24 - 3 (status bar) - 3 (header) = 18 + + // Test without header + assert_eq!(estimate_page_size(area, false), 21); // 24 - 3 (status bar) = 21 + } +} From 968eb45fb29bb687327dfe7d67e1eb792c1a4d5a Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Thu, 20 Mar 2025 06:49:12 -0700 Subject: [PATCH 37/59] Don't collect job output (#15365) # Description Fixes #15359. # User-Facing Changes Bug fix. --- crates/nu-command/src/experimental/job_spawn.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/nu-command/src/experimental/job_spawn.rs b/crates/nu-command/src/experimental/job_spawn.rs index 80cd20c0e7..60f30024be 100644 --- a/crates/nu-command/src/experimental/job_spawn.rs +++ b/crates/nu-command/src/experimental/job_spawn.rs @@ -8,8 +8,8 @@ use std::{ use nu_engine::{command_prelude::*, ClosureEvalOnce}; use nu_protocol::{ - engine::{Closure, Job, ThreadJob}, - report_shell_error, Signals, + engine::{Closure, Job, Redirection, ThreadJob}, + report_shell_error, OutDest, Signals, }; #[derive(Clone)] @@ -76,15 +76,18 @@ impl Command for JobSpawn { let result = thread::Builder::new() .name(format!("background job {}", id.get())) .spawn(move || { - ClosureEvalOnce::new(&job_state, &job_stack, closure) + let mut stack = job_stack.reset_pipes(); + let stack = stack.push_redirection( + Some(Redirection::Pipe(OutDest::Null)), + Some(Redirection::Pipe(OutDest::Null)), + ); + ClosureEvalOnce::new_preserve_out_dest(&job_state, &stack, closure) .run_with_input(Value::nothing(head).into_pipeline_data()) - .and_then(|data| data.into_value(head)) + .and_then(|data| data.drain()) .unwrap_or_else(|err| { if !job_state.signals().interrupted() { report_shell_error(&job_state, &err); } - - Value::nothing(head) }); { From 820d0c0959feeb87644fe20f759b53f74663d1c8 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 20 Mar 2025 09:51:48 -0500 Subject: [PATCH 38/59] bump uutils crates to 0.0.30 (#15316) # Description Bump the uutils crates to 0.0.30. This bump changed a lot of deps in the lock file. I'm not sure if we should wait a bit on this or just go for it. # User-Facing Changes # Tests + Formatting # After Submitting --- Cargo.lock | 235 +++++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 16 ++-- 2 files changed, 173 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47ccd53a6b..9bc67a0a32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,10 +30,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -111,7 +111,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "220044e6a1bb31ddee4e3db724d29767f352de47445a6cd75e1a173142136c83" dependencies = [ - "nom", + "nom 7.1.3", "vte 0.10.1", ] @@ -908,7 +908,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom", + "nom 7.1.3", ] [[package]] @@ -1146,7 +1146,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom", + "getrandom 0.2.15", "once_cell", "tiny-keccak", ] @@ -2091,10 +2091,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", +] + [[package]] name = "gimli" version = "0.31.1" @@ -3285,7 +3297,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -3297,7 +3309,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -3316,7 +3328,7 @@ dependencies = [ "hyper 1.5.1", "hyper-util", "log", - "rand", + "rand 0.8.5", "regex", "serde_json", "serde_urlencoded", @@ -3395,6 +3407,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + [[package]] name = "notify" version = "6.1.1" @@ -3637,7 +3658,7 @@ dependencies = [ "fancy-regex", "filesize", "filetime", - "getrandom", + "getrandom 0.2.15", "human-date-parser", "indexmap", "indicatif", @@ -3680,8 +3701,8 @@ dependencies = [ "print-positions", "procfs", "quick-xml 0.37.1", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "rayon", "rmp", "roxmltree", @@ -3924,7 +3945,7 @@ version = "0.103.1" dependencies = [ "heapless", "nu-ansi-term", - "rand", + "rand 0.8.5", ] [[package]] @@ -4415,7 +4436,7 @@ dependencies = [ "parking_lot", "percent-encoding", "quick-xml 0.37.1", - "rand", + "rand 0.8.5", "reqwest", "ring", "serde", @@ -4610,12 +4631,12 @@ dependencies = [ [[package]] name = "parse_datetime" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8720474e3dd4af20cea8716703498b9f3b690f318fa9d9d9e2e38eaf44b96d0" +checksum = "4bffd1156cebf13f681d7769924d3edfb9d9d71ba206a8d8e8e7eb9df4f4b1e7" dependencies = [ "chrono", - "nom", + "nom 8.0.0", "regex", ] @@ -4725,7 +4746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared 0.10.0", - "rand", + "rand 0.8.5", ] [[package]] @@ -4735,7 +4756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand", + "rand 0.8.5", ] [[package]] @@ -4831,7 +4852,7 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72571dde488ecccbe799798bf99ab7308ebdb7cf5d95bcc498dbd5a132f0da4d" dependencies = [ - "getrandom", + "getrandom 0.2.15", "polars-arrow", "polars-core", "polars-error", @@ -4861,7 +4882,7 @@ dependencies = [ "dyn-clone", "either", "ethnum", - "getrandom", + "getrandom 0.2.15", "hashbrown 0.15.2", "itoa", "lz4", @@ -4936,7 +4957,7 @@ dependencies = [ "polars-row", "polars-schema", "polars-utils", - "rand", + "rand 0.8.5", "rand_distr", "rayon", "regex", @@ -4982,7 +5003,7 @@ dependencies = [ "polars-row", "polars-time", "polars-utils", - "rand", + "rand 0.8.5", "rayon", ] @@ -5136,7 +5157,7 @@ dependencies = [ "polars-json", "polars-schema", "polars-utils", - "rand", + "rand 0.8.5", "rand_distr", "rayon", "regex", @@ -5293,7 +5314,7 @@ dependencies = [ "polars-plan", "polars-time", "polars-utils", - "rand", + "rand 0.8.5", "regex", "serde", "sqlparser", @@ -5321,7 +5342,7 @@ dependencies = [ "polars-parquet", "polars-plan", "polars-utils", - "rand", + "rand 0.8.5", "rayon", "recursive", "slotmap", @@ -5373,7 +5394,7 @@ dependencies = [ "num-traits", "once_cell", "polars-error", - "rand", + "rand 0.8.5", "raw-cpuid", "rayon", "serde", @@ -5389,7 +5410,7 @@ version = "0.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a63d338dec139f56dacc692ca63ad35a6be6a797442479b55acd611d79e906" dependencies = [ - "nom", + "nom 7.1.3", ] [[package]] @@ -5410,7 +5431,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -5604,7 +5625,7 @@ checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "env_logger 0.8.4", "log", - "rand", + "rand 0.8.5", ] [[package]] @@ -5643,8 +5664,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", - "getrandom", - "rand", + "getrandom 0.2.15", + "rand 0.8.5", "ring", "rustc-hash 2.1.0", "rustls 0.23.20", @@ -5692,8 +5713,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy 0.8.23", ] [[package]] @@ -5703,7 +5735,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -5712,7 +5754,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", ] [[package]] @@ -5722,7 +5773,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -5816,7 +5867,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.15", "libredox", "thiserror 1.0.69", ] @@ -5976,7 +6027,7 @@ checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "untrusted", "windows-sys 0.52.0", @@ -6050,7 +6101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a8fb4672e840a587a66fc577a5491375df51ddb88f2a2c2a792598c326fe14" dependencies = [ "quote", - "rand", + "rand 0.8.5", "syn 2.0.90", ] @@ -6619,7 +6670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa2bcf6c6e164e81bc7a5d49fc6988b3d515d9e8c07457d7b74ffb9324b9cd40" dependencies = [ "ahash", - "getrandom", + "getrandom 0.2.15", "halfbrown", "once_cell", "ref-cast", @@ -6976,7 +7027,7 @@ dependencies = [ "libloading", "log", "num-traits", - "rand", + "rand 0.8.5", "scroll", "tempfile", "thiserror 1.0.69", @@ -6990,7 +7041,7 @@ checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.2.15", "once_cell", "rustix", "windows-sys 0.59.0", @@ -7338,7 +7389,7 @@ checksum = "aac5e8971f245c3389a5a76e648bfc80803ae066a1243a75db0064d7c1129d63" dependencies = [ "fnv", "memchr", - "nom", + "nom 7.1.3", "once_cell", "petgraph", ] @@ -7569,9 +7620,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uu_cp" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235439f8efcff799cbdb90992cb5b1845dce903c1569efc8d9b46417c83f5aa8" +checksum = "bf2f3906b7896f79519055d36760095577373e40ec244f46b259f502a4a91147" dependencies = [ "clap", "filetime", @@ -7585,9 +7636,9 @@ dependencies = [ [[package]] name = "uu_mkdir" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0a30620d88a7ea16b522e1fe63ebb61f87f05fd63ade00938a024807356952" +checksum = "5be556a5d852f55b92bba460d7a97030a340ba4a3f4c510a8d0a893bfaf48356" dependencies = [ "clap", "uucore", @@ -7595,47 +7646,52 @@ dependencies = [ [[package]] name = "uu_mktemp" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1db7648ff064cdfe8a0e6ef9546de3b03e34cefa270b783de7736a8470473cc" +checksum = "5305fcf4f7f480e7438e19ff433ae60dea886bd528f87543029eb6b95d351afc" dependencies = [ "clap", - "rand", + "rand 0.9.0", "tempfile", + "thiserror 2.0.6", "uucore", ] [[package]] name = "uu_mv" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ab8c17ac7153adaa0176924319827cfb240cf48e4260283facfdb37e776071" +checksum = "3be214b96554e4f7aa079b26c86c3ecf1b9ea15023ca2ec62d608273d12c7049" dependencies = [ "clap", "fs_extra", "indicatif", + "libc", + "thiserror 2.0.6", "uucore", + "windows-sys 0.59.0", ] [[package]] name = "uu_touch" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3adc774c7961272cd2feeb95f2bf2e0b8f7b8ccd5fbcf49727d0de1eab804b67" +checksum = "1e58581a0245de8e3ef75b115ab29592cfb60d4851149d4951604601d14ea420" dependencies = [ "chrono", "clap", "filetime", "parse_datetime", + "thiserror 2.0.6", "uucore", "windows-sys 0.59.0", ] [[package]] name = "uu_uname" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a942626aec03d4f4d972b10e00f9ddcdced1933658076eccafea5a20fdafb8" +checksum = "324d96a21da91a81be334206ab65aad16d164d34cddeb640e1c56cd8d1854dd4" dependencies = [ "clap", "platform-info", @@ -7644,9 +7700,9 @@ dependencies = [ [[package]] name = "uu_whoami" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a812f7a838c9375c15ed13b66048df2c632c1ac3ec613dabb28c648019c6d018" +checksum = "bee254de8b172a5978f12fe6cd9d4f2b60ea9ef1e37f0cb53bfee2c993b3e96a" dependencies = [ "clap", "libc", @@ -7656,18 +7712,19 @@ dependencies = [ [[package]] name = "uucore" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e0dc1598d959a08f24cea4d9e992f7ca874bd4ac80746683272afd37603b5e" +checksum = "71f4e82877d06de779c611a3d54720f56f1e68b228fb30a5b6c66ef07e68263d" dependencies = [ + "chrono", + "chrono-tz", "clap", "dunce", "glob", - "lazy_static", + "iana-time-zone", "libc", "nix 0.29.0", "number_prefix", - "once_cell", "os_display", "uucore_procs", "walkdir", @@ -7679,9 +7736,9 @@ dependencies = [ [[package]] name = "uucore_procs" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27d3de33ab2b56c0437cca084a2aeb1d46c56d138ab6341c009a90018a9a1c5f" +checksum = "c72435859e812e602e225dea48d014abb6b1072220a8d44f2fe0565553b1f7e4" dependencies = [ "proc-macro2", "quote", @@ -7690,9 +7747,9 @@ dependencies = [ [[package]] name = "uuhelp_parser" -version = "0.0.29" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cf4c8b31abfb5dc79940d6ca8000a1a6aa42f38711cdeaacb95850c69924cbc" +checksum = "0bb6d972f580f8223cb7052d8580aea2b7061e368cf476de32ea9457b19459ed" [[package]] name = "uuid" @@ -7701,7 +7758,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" dependencies = [ "atomic", - "getrandom", + "getrandom 0.2.15", "md-5", "serde", "sha1_smol", @@ -7808,6 +7865,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.99" @@ -7896,7 +7962,7 @@ checksum = "8d12a78aa0bab22d2f26ed1a96df7ab58e8a93506a3e20adb47c51a93b4e1357" dependencies = [ "const_format", "itertools 0.11.0", - "nom", + "nom 7.1.3", "pori", "regex", "thiserror 1.0.69", @@ -8387,6 +8453,15 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "wl-clipboard-rs" version = "0.8.1" @@ -8507,7 +8582,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive 0.8.23", ] [[package]] @@ -8521,6 +8605,17 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index 545cb6f1cd..01e43f929b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,14 +170,14 @@ unicode-segmentation = "1.12" unicode-width = "0.2" ureq = { version = "2.12", default-features = false } url = "2.2" -uu_cp = "0.0.29" -uu_mkdir = "0.0.29" -uu_mktemp = "0.0.29" -uu_mv = "0.0.29" -uu_touch = "0.0.29" -uu_whoami = "0.0.29" -uu_uname = "0.0.29" -uucore = "0.0.29" +uu_cp = "0.0.30" +uu_mkdir = "0.0.30" +uu_mktemp = "0.0.30" +uu_mv = "0.0.30" +uu_touch = "0.0.30" +uu_whoami = "0.0.30" +uu_uname = "0.0.30" +uucore = "0.0.30" uuid = "1.12.0" v_htmlescape = "0.15.0" wax = "0.6" From 862d53bb6efe175bb6910de90fffc749bbd309f2 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 20 Mar 2025 09:53:19 -0500 Subject: [PATCH 39/59] add more columns to macos `ps -l` (#15341) # Description This PR adds a few more columns to the macos version of `ps -l` to bring it more inline with the Linux and Windows version. Columns added: user_id, priority, process_threads I also added some comments that describe the TaskInfo structure. I couldn't find any good information to add to the BSDInfo structure. # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/system/ps.rs | 5 ++++- crates/nu-system/src/macos.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index cece41e56f..39656337d1 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -176,11 +176,14 @@ fn run_ps( } #[cfg(target_os = "macos")] { - record.push("cwd", Value::string(proc.cwd(), span)); let timestamp = Local .timestamp_nanos(proc.start_time * 1_000_000_000) .into(); record.push("start_time", Value::date(timestamp, span)); + record.push("user_id", Value::int(proc.user_id, span)); + record.push("priority", Value::int(proc.priority, span)); + record.push("process_threads", Value::int(proc.task_thread_num, span)); + record.push("cwd", Value::string(proc.cwd(), span)); } } diff --git a/crates/nu-system/src/macos.rs b/crates/nu-system/src/macos.rs index 8d6ab59d4b..4978f50e7f 100644 --- a/crates/nu-system/src/macos.rs +++ b/crates/nu-system/src/macos.rs @@ -26,6 +26,9 @@ pub struct ProcessInfo { pub prev_res: Option, pub interval: Duration, pub start_time: i64, + pub user_id: i64, + pub priority: i64, + pub task_thread_num: i64, } pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec { @@ -96,6 +99,9 @@ pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec let interval = curr_time.saturating_duration_since(prev_time); let ppid = curr_task.pbsd.pbi_ppid as i32; let start_time = curr_task.pbsd.pbi_start_tvsec as i64; + let user_id = curr_task.pbsd.pbi_uid as i64; + let priority = curr_task.ptinfo.pti_priority as i64; + let task_thread_num = curr_task.ptinfo.pti_threadnum as i64; let proc = ProcessInfo { pid, @@ -110,6 +116,9 @@ pub fn collect_proc(interval: Duration, _with_thread: bool) -> Vec prev_res, interval, start_time, + user_id, + priority, + task_thread_num, }; ret.push(proc); @@ -276,24 +285,44 @@ fn clone_task_all_info(src: &TaskAllInfo) -> TaskAllInfo { pbi_start_tvsec: src.pbsd.pbi_start_tvsec, pbi_start_tvusec: src.pbsd.pbi_start_tvusec, }; + + // Comments taken from here https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/sys/proc_info.h#L127 let ptinfo = TaskInfo { + // virtual memory size (bytes) pti_virtual_size: src.ptinfo.pti_virtual_size, + // resident memory size (bytes) pti_resident_size: src.ptinfo.pti_resident_size, + // total user time pti_total_user: src.ptinfo.pti_total_user, + // total system time pti_total_system: src.ptinfo.pti_total_system, + // existing threads only user pti_threads_user: src.ptinfo.pti_threads_user, + // existing threads only system pti_threads_system: src.ptinfo.pti_threads_system, + // default policy for new threads pti_policy: src.ptinfo.pti_policy, + // number of page faults pti_faults: src.ptinfo.pti_faults, + // number of actual pageins pti_pageins: src.ptinfo.pti_pageins, + // number of copy-on-write faults pti_cow_faults: src.ptinfo.pti_cow_faults, + // number of messages sent pti_messages_sent: src.ptinfo.pti_messages_sent, + // number of messages received pti_messages_received: src.ptinfo.pti_messages_received, + // number of mach system calls pti_syscalls_mach: src.ptinfo.pti_syscalls_mach, + // number of unix system calls pti_syscalls_unix: src.ptinfo.pti_syscalls_unix, + // number of context switches pti_csw: src.ptinfo.pti_csw, + // number of threads in the task pti_threadnum: src.ptinfo.pti_threadnum, + // number of running threads pti_numrunning: src.ptinfo.pti_numrunning, + // task priority pti_priority: src.ptinfo.pti_priority, }; TaskAllInfo { pbsd, ptinfo } From e89bb2ee96f6c5ae4b40a27f21933516e866453c Mon Sep 17 00:00:00 2001 From: zc he Date: Thu, 20 Mar 2025 22:55:03 +0800 Subject: [PATCH 40/59] fix(lsp): verbose signature help response for less well supported editors (#15353) # Description Some editors (like zed) will fail to mark the active parameter if not set in the outmost structure. # User-Facing Changes # Tests + Formatting Adjusted # After Submitting --- crates/nu-lsp/src/lib.rs | 2 +- crates/nu-lsp/src/signature.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/nu-lsp/src/lib.rs b/crates/nu-lsp/src/lib.rs index bcce8dcf89..027c1ffe8c 100644 --- a/crates/nu-lsp/src/lib.rs +++ b/crates/nu-lsp/src/lib.rs @@ -660,7 +660,7 @@ mod tests { client_connection .receiver - .recv_timeout(Duration::from_secs(2)) + .recv_timeout(Duration::from_secs(3)) .unwrap() } } diff --git a/crates/nu-lsp/src/signature.rs b/crates/nu-lsp/src/signature.rs index 263a29dacb..aca08477e2 100644 --- a/crates/nu-lsp/src/signature.rs +++ b/crates/nu-lsp/src/signature.rs @@ -162,15 +162,16 @@ impl LanguageServer { parameters.push(arg_to_param_info(rest_arg)); } let max_idx = parameters.len().saturating_sub(1) as u32; + let active_parameter = Some(param_num_before_pos.min(max_idx)); Some(SignatureHelp { signatures: vec![SignatureInformation { label: Self::get_signature_label(&active_signature), documentation: str_to_doc(active_signature.description), parameters: Some(parameters), - active_parameter: Some(std::cmp::min(param_num_before_pos, max_idx)), + active_parameter, }], active_signature: Some(0), - active_parameter: None, + active_parameter, }) } } @@ -315,7 +316,8 @@ mod tests { ], "activeParameter": 1 }], - "activeSignature": 0 + "activeSignature": 0, + "activeParameter": 1 }) ); @@ -332,7 +334,8 @@ mod tests { ], "activeParameter": 2 }], - "activeSignature": 0 + "activeSignature": 0, + "activeParameter": 2 }) ); } From 8b80ceac329edcf5b11871ac41baa73dd2f6ab23 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Thu, 20 Mar 2025 11:42:31 -0400 Subject: [PATCH 41/59] Add From for LabeledError (#15327) # Description Adds an `impl From for LabeledError`, similar to the existing `From` implementation. Helpful for plugins. # User-Facing Changes N/A # Tests + Formatting N/A # After Submitting N/A --- crates/nu-protocol/src/errors/labeled_error.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/errors/labeled_error.rs b/crates/nu-protocol/src/errors/labeled_error.rs index 7104a1a8b1..810ec5a880 100644 --- a/crates/nu-protocol/src/errors/labeled_error.rs +++ b/crates/nu-protocol/src/errors/labeled_error.rs @@ -1,4 +1,4 @@ -use super::ShellError; +use super::{shell_error::io::IoError, ShellError}; use crate::Span; use miette::Diagnostic; use serde::{Deserialize, Serialize}; @@ -247,3 +247,9 @@ impl From for LabeledError { LabeledError::from_diagnostic(&err) } } + +impl From for LabeledError { + fn from(err: IoError) -> Self { + LabeledError::from_diagnostic(&err) + } +} From 2b4914608eb965a1dcbf27efff6556e1dee85e73 Mon Sep 17 00:00:00 2001 From: zc he Date: Thu, 20 Mar 2025 23:44:41 +0800 Subject: [PATCH 42/59] fix(completion): inline defined custom completion (#15318) Fixes #6001 # Description image # User-Facing Changes # Tests + Formatting +1 # After Submitting --- .../src/completions/custom_completions.rs | 55 +++++++++++-------- crates/nu-cli/tests/completions/mod.rs | 15 +++++ 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/crates/nu-cli/src/completions/custom_completions.rs b/crates/nu-cli/src/completions/custom_completions.rs index 317c865de1..32f088db52 100644 --- a/crates/nu-cli/src/completions/custom_completions.rs +++ b/crates/nu-cli/src/completions/custom_completions.rs @@ -5,7 +5,7 @@ use nu_engine::eval_call; use nu_protocol::{ ast::{Argument, Call, Expr, Expression}, debugger::WithoutDebug, - engine::{Stack, StateWorkingSet}, + engine::{EngineState, Stack, StateWorkingSet}, DeclId, PipelineData, Span, Type, Value, }; use std::collections::HashMap; @@ -42,28 +42,37 @@ impl Completer for CustomCompletion { ) -> Vec { // Call custom declaration let mut stack_mut = stack.clone(); - let result = eval_call::( - working_set.permanent_state, - &mut stack_mut, - &Call { - decl_id: self.decl_id, - head: span, - arguments: vec![ - Argument::Positional(Expression::new_unknown( - Expr::String(self.line.clone()), - Span::unknown(), - Type::String, - )), - Argument::Positional(Expression::new_unknown( - Expr::Int(self.line_pos as i64), - Span::unknown(), - Type::Int, - )), - ], - parser_info: HashMap::new(), - }, - PipelineData::empty(), - ); + let mut eval = |engine_state: &EngineState| { + eval_call::( + engine_state, + &mut stack_mut, + &Call { + decl_id: self.decl_id, + head: span, + arguments: vec![ + Argument::Positional(Expression::new_unknown( + Expr::String(self.line.clone()), + Span::unknown(), + Type::String, + )), + Argument::Positional(Expression::new_unknown( + Expr::Int(self.line_pos as i64), + Span::unknown(), + Type::Int, + )), + ], + parser_info: HashMap::new(), + }, + PipelineData::empty(), + ) + }; + let result = if self.decl_id.get() < working_set.permanent_state.num_decls() { + eval(working_set.permanent_state) + } else { + let mut engine_state = working_set.permanent_state.clone(); + let _ = engine_state.merge_delta(working_set.delta.clone()); + eval(&engine_state) + }; let mut completion_options = orig_options.clone(); let mut should_sort = true; diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index 0326c9ba84..4e1e5b0fdb 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -350,6 +350,21 @@ fn custom_arguments_vs_subcommands() { match_suggestions(&expected, &suggestions); } +#[test] +fn custom_completions_defined_inline() { + let (_, _, engine, stack) = new_engine(); + + let mut completer = NuCompleter::new(Arc::new(engine), Arc::new(stack)); + let completion_str = "def animals [] { [cat dog] } +export def say [ + animal: string@animals +] { }; say "; + let suggestions = completer.complete(completion_str, completion_str.len()); + // including only subcommand completions + let expected: Vec<_> = vec!["cat", "dog"]; + match_suggestions(&expected, &suggestions); +} + /// External command only if starts with `^` #[test] fn external_commands_only() { From c99c8119fe08888e507a6471ff533b1dce746e7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:45:58 +0000 Subject: [PATCH 43/59] build(deps): bump indexmap from 2.7.0 to 2.8.0 (#15345) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/nu_plugin_polars/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bc67a0a32..0cad36ed6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2695,9 +2695,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown 0.15.2", diff --git a/Cargo.toml b/Cargo.toml index 01e43f929b..fbd1a134d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ filesize = "0.2" filetime = "0.2" heck = "0.5.0" human-date-parser = "0.2.0" -indexmap = "2.7" +indexmap = "2.8" indicatif = "0.17" interprocess = "2.2.0" is_executable = "1.0" diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index 1989a10bc3..0deb318ed8 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -26,7 +26,7 @@ nu-utils = { path = "../nu-utils", version = "0.103.1" } chrono = { workspace = true, features = ["std", "unstable-locales"], default-features = false } chrono-tz = "0.10" fancy-regex = { workspace = true } -indexmap = { version = "2.7" } +indexmap = { version = "2.8" } num = {version = "0.4"} serde = { version = "1.0", features = ["derive"] } sqlparser = { version = "0.53"} From 946cef77f11116ad41489cc3a5526033c9bfe3e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:46:25 +0000 Subject: [PATCH 44/59] build(deps): bump uuid from 1.12.0 to 1.16.0 (#15346) --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- crates/nu_plugin_polars/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0cad36ed6b..b25defee90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7753,12 +7753,12 @@ checksum = "0bb6d972f580f8223cb7052d8580aea2b7061e368cf476de32ea9457b19459ed" [[package]] name = "uuid" -version = "1.12.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ "atomic", - "getrandom 0.2.15", + "getrandom 0.3.1", "md-5", "serde", "sha1_smol", diff --git a/Cargo.toml b/Cargo.toml index fbd1a134d4..79f5533082 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,7 +178,7 @@ uu_touch = "0.0.30" uu_whoami = "0.0.30" uu_uname = "0.0.30" uucore = "0.0.30" -uuid = "1.12.0" +uuid = "1.16.0" v_htmlescape = "0.15.0" wax = "0.6" web-time = "1.1.0" diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index 0deb318ed8..ce91ab3d2f 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -38,7 +38,7 @@ polars-utils = { version = "0.46"} typetag = "0.2" env_logger = "0.11.3" log.workspace = true -uuid = { version = "1.12", features = ["v4", "serde"] } +uuid = { version = "1.16", features = ["v4", "serde"] } # Do to a compile error with polars, this included to force the raw dependency hashbrown = { version = "0.15", features = ["rayon", "serde"] } From b241e9edd5adb283e668af2eab254096186f4f2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:51:22 +0000 Subject: [PATCH 45/59] build(deps): bump mockito from 1.6.1 to 1.7.0 (#15343) --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b25defee90..3c3cc03bbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3315,9 +3315,9 @@ dependencies = [ [[package]] name = "mockito" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "652cd6d169a36eaf9d1e6bce1a221130439a966d7f27858af66a33a66e9c4ee2" +checksum = "7760e0e418d9b7e5777c0374009ca4c93861b9066f18cb334a20ce50ab63aa48" dependencies = [ "assert-json-diff", "bytes", @@ -3328,7 +3328,7 @@ dependencies = [ "hyper 1.5.1", "hyper-util", "log", - "rand 0.8.5", + "rand 0.9.0", "regex", "serde_json", "serde_urlencoded", diff --git a/Cargo.toml b/Cargo.toml index 79f5533082..3d11084007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,7 +110,7 @@ md5 = { version = "0.10", package = "md-5" } miette = "7.5" mime = "0.3.17" mime_guess = "2.0" -mockito = { version = "1.6", default-features = false } +mockito = { version = "1.7", default-features = false } multipart-rs = "0.1.13" native-tls = "0.2" nix = { version = "0.29", default-features = false } From dfba62da00599731d594eb20eb9c4196e7f049af Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Thu, 20 Mar 2025 09:32:41 -0700 Subject: [PATCH 46/59] Remove `nu-glob`'s dependency on `nu-protocol` (#15349) # Description This PR solves a circular dependency issue (`nu-test-support` needs `nu-glob` which needs `nu-protocol` which needs `nu-test-support`). This was done by making the glob functions that any type that implements `Interruptible` to remove the dependency on `Signals`. # After Submitting Make `Paths.next()` a O(1) operation so that cancellation/interrupt handling can be moved to the caller (e.g., by wrapping the `Paths` iterator in a cancellation iterator). --- Cargo.lock | 2 +- crates/nu-command/src/filesystem/utouch.rs | 20 ++-- crates/nu-glob/Cargo.toml | 3 +- crates/nu-glob/src/lib.rs | 96 +++++++++++-------- crates/nu-lsp/src/workspace.rs | 3 +- crates/nu-protocol/Cargo.toml | 1 + crates/nu-protocol/src/pipeline/signals.rs | 11 ++- crates/nu-test-support/src/playground/play.rs | 4 +- 8 files changed, 81 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c3cc03bbd..28017902c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3795,7 +3795,6 @@ name = "nu-glob" version = "0.103.1" dependencies = [ "doc-comment", - "nu-protocol", ] [[package]] @@ -3967,6 +3966,7 @@ dependencies = [ "miette", "nix 0.29.0", "nu-derive-value", + "nu-glob", "nu-path", "nu-system", "nu-test-support", diff --git a/crates/nu-command/src/filesystem/utouch.rs b/crates/nu-command/src/filesystem/utouch.rs index 53798ebc81..48077b0179 100644 --- a/crates/nu-command/src/filesystem/utouch.rs +++ b/crates/nu-command/src/filesystem/utouch.rs @@ -158,17 +158,15 @@ impl Command for UTouch { continue; } - let mut expanded_globs = glob( - &file_path.to_string_lossy(), - Some(engine_state.signals().clone()), - ) - .unwrap_or_else(|_| { - panic!( - "Failed to process file path: {}", - &file_path.to_string_lossy() - ) - }) - .peekable(); + let mut expanded_globs = + glob(&file_path.to_string_lossy(), engine_state.signals().clone()) + .unwrap_or_else(|_| { + panic!( + "Failed to process file path: {}", + &file_path.to_string_lossy() + ) + }) + .peekable(); if expanded_globs.peek().is_none() { let file_name = file_path.file_name().unwrap_or_else(|| { diff --git a/crates/nu-glob/Cargo.toml b/crates/nu-glob/Cargo.toml index b1f4835429..a6d797e4db 100644 --- a/crates/nu-glob/Cargo.toml +++ b/crates/nu-glob/Cargo.toml @@ -14,10 +14,9 @@ categories = ["filesystem"] bench = false [dependencies] -nu-protocol = { path = "../nu-protocol", version = "0.103.1", default-features = false } [dev-dependencies] doc-comment = "0.3" [lints] -workspace = true \ No newline at end of file +workspace = true diff --git a/crates/nu-glob/src/lib.rs b/crates/nu-glob/src/lib.rs index b733cc1bda..67f57cd119 100644 --- a/crates/nu-glob/src/lib.rs +++ b/crates/nu-glob/src/lib.rs @@ -27,9 +27,9 @@ //! To print all jpg files in `/media/` and all of its subdirectories. //! //! ```rust,no_run -//! use nu_glob::glob; +//! use nu_glob::{glob, Uninterruptible}; //! -//! for entry in glob("/media/**/*.jpg", None).expect("Failed to read glob pattern") { +//! for entry in glob("/media/**/*.jpg", Uninterruptible).expect("Failed to read glob pattern") { //! match entry { //! Ok(path) => println!("{:?}", path.display()), //! Err(e) => println!("{:?}", e), @@ -42,9 +42,7 @@ //! instead of printing them. //! //! ```rust,no_run -//! use nu_glob::glob_with; -//! use nu_glob::MatchOptions; -//! use nu_protocol::Signals; +//! use nu_glob::{glob_with, MatchOptions, Uninterruptible}; //! //! let options = MatchOptions { //! case_sensitive: false, @@ -52,7 +50,7 @@ //! require_literal_leading_dot: false, //! recursive_match_hidden_dir: true, //! }; -//! for entry in glob_with("local/*a*", options, Signals::empty()).unwrap() { +//! for entry in glob_with("local/*a*", options, Uninterruptible).unwrap() { //! if let Ok(path) = entry { //! println!("{:?}", path.display()) //! } @@ -73,7 +71,6 @@ extern crate doc_comment; #[cfg(test)] doctest!("../README.md"); -use nu_protocol::Signals; use std::cmp; use std::cmp::Ordering; use std::error::Error; @@ -88,6 +85,29 @@ use MatchResult::{EntirePatternDoesntMatch, Match, SubPatternDoesntMatch}; use PatternToken::AnyExcept; use PatternToken::{AnyChar, AnyRecursiveSequence, AnySequence, AnyWithin, Char}; +/// A trait for types that can be periodically polled to check whether to cancel an operation. +pub trait Interruptible { + /// Returns whether the current operation should be cancelled. + fn interrupted(&self) -> bool; +} + +impl Interruptible for &I { + #[inline] + fn interrupted(&self) -> bool { + (*self).interrupted() + } +} + +/// A no-op implementor of [`Interruptible`] that always returns `false` for [`interrupted`](Interruptible::interrupted). +pub struct Uninterruptible; + +impl Interruptible for Uninterruptible { + #[inline] + fn interrupted(&self) -> bool { + false + } +} + /// An iterator that yields `Path`s from the filesystem that match a particular /// pattern. /// @@ -98,16 +118,16 @@ use PatternToken::{AnyChar, AnyRecursiveSequence, AnySequence, AnyWithin, Char}; /// /// See the `glob` function for more details. #[derive(Debug)] -pub struct Paths { +pub struct Paths { dir_patterns: Vec, require_dir: bool, options: MatchOptions, todo: Vec>, scope: Option, - signals: Signals, + interrupt: I, } -impl Paths { +impl Paths { /// An iterator representing a single path. pub fn single(path: &Path, relative_to: &Path) -> Self { Paths { @@ -116,7 +136,7 @@ impl Paths { options: MatchOptions::default(), todo: vec![Ok((path.to_path_buf(), 0))], scope: Some(relative_to.into()), - signals: Signals::empty(), + interrupt: Uninterruptible, } } } @@ -133,7 +153,7 @@ impl Paths { /// /// When iterating, each result is a `GlobResult` which expresses the /// possibility that there was an `IoError` when attempting to read the contents -/// of the matched path. In other words, each item returned by the iterator +/// of the matched path. In other words, each item returned by the iterator /// will either be an `Ok(Path)` if the path matched, or an `Err(GlobError)` if /// the path (partially) matched _but_ its contents could not be read in order /// to determine if its contents matched. @@ -146,9 +166,9 @@ impl Paths { /// `kittens.jpg`, `puppies.jpg` and `hamsters.gif`: /// /// ```rust,no_run -/// use nu_glob::glob; +/// use nu_glob::{glob, Uninterruptible}; /// -/// for entry in glob("/media/pictures/*.jpg", None).unwrap() { +/// for entry in glob("/media/pictures/*.jpg", Uninterruptible).unwrap() { /// match entry { /// Ok(path) => println!("{:?}", path.display()), /// @@ -170,20 +190,16 @@ impl Paths { /// `filter_map`: /// /// ```rust -/// use nu_glob::glob; +/// use nu_glob::{glob, Uninterruptible}; /// use std::result::Result; /// -/// for path in glob("/media/pictures/*.jpg", None).unwrap().filter_map(Result::ok) { +/// for path in glob("/media/pictures/*.jpg", Uninterruptible).unwrap().filter_map(Result::ok) { /// println!("{}", path.display()); /// } /// ``` /// Paths are yielded in alphabetical order. -pub fn glob(pattern: &str, signals: Option) -> Result { - glob_with( - pattern, - MatchOptions::default(), - signals.unwrap_or(Signals::empty()), - ) +pub fn glob(pattern: &str, interrupt: I) -> Result, PatternError> { + glob_with(pattern, MatchOptions::default(), interrupt) } /// Return an iterator that produces all the `Path`s that match the given @@ -199,11 +215,11 @@ pub fn glob(pattern: &str, signals: Option) -> Result( pattern: &str, options: MatchOptions, - signals: Signals, -) -> Result { + interrupt: I, +) -> Result, PatternError> { #[cfg(windows)] fn check_windows_verbatim(p: &Path) -> bool { match p.components().next() { @@ -265,7 +281,7 @@ pub fn glob_with( options, todo: Vec::new(), scope: None, - signals, + interrupt, }); } @@ -297,7 +313,7 @@ pub fn glob_with( options, todo, scope: Some(scope), - signals, + interrupt, }) } @@ -308,13 +324,13 @@ pub fn glob_with( /// This is provided primarily for testability, so multithreaded test runners can /// test pattern matches in different test directories at the same time without /// having to append the parent to the pattern under test. -pub fn glob_with_parent( +pub fn glob_with_parent( pattern: &str, options: MatchOptions, parent: &Path, - signals: Signals, -) -> Result { - match glob_with(pattern, options, signals) { + interrupt: I, +) -> Result, PatternError> { + match glob_with(pattern, options, interrupt) { Ok(mut p) => { p.scope = match p.scope { None => Some(parent.to_path_buf()), @@ -408,7 +424,7 @@ fn is_dir(p: &Path) -> bool { /// such as failing to read a particular directory's contents. pub type GlobResult = Result; -impl Iterator for Paths { +impl Iterator for Paths { type Item = GlobResult; fn next(&mut self) -> Option { @@ -429,7 +445,7 @@ impl Iterator for Paths { 0, &scope, self.options, - &self.signals, + &self.interrupt, ); } } @@ -487,7 +503,7 @@ impl Iterator for Paths { next, &path, self.options, - &self.signals, + &self.interrupt, ); if next == self.dir_patterns.len() - 1 { @@ -539,7 +555,7 @@ impl Iterator for Paths { idx + 1, &path, self.options, - &self.signals, + &self.interrupt, ); } } @@ -929,7 +945,7 @@ fn fill_todo( idx: usize, path: &Path, options: MatchOptions, - signals: &Signals, + interrupt: &impl Interruptible, ) { // convert a pattern that's just many Char(_) to a string fn pattern_as_str(pattern: &Pattern) -> Option { @@ -951,7 +967,7 @@ fn fill_todo( // . or .. globs since these never show up as path components. todo.push(Ok((next_path, !0))); } else { - fill_todo(todo, patterns, idx + 1, &next_path, options, signals); + fill_todo(todo, patterns, idx + 1, &next_path, options, interrupt); } }; @@ -982,7 +998,7 @@ fn fill_todo( None if is_dir => { let dirs = fs::read_dir(path).and_then(|d| { d.map(|e| { - if signals.interrupted() { + if interrupt.interrupted() { return Err(io::Error::from(io::ErrorKind::Interrupted)); } e.map(|e| { @@ -1141,13 +1157,13 @@ impl Default for MatchOptions { #[cfg(test)] mod test { - use crate::{Paths, PatternError}; + use crate::{Paths, PatternError, Uninterruptible}; use super::{glob as glob_with_signals, MatchOptions, Pattern}; use std::path::Path; fn glob(pattern: &str) -> Result { - glob_with_signals(pattern, None) + glob_with_signals(pattern, Uninterruptible) } #[test] diff --git a/crates/nu-lsp/src/workspace.rs b/crates/nu-lsp/src/workspace.rs index 66b70f58ea..9950a3c0f8 100644 --- a/crates/nu-lsp/src/workspace.rs +++ b/crates/nu-lsp/src/workspace.rs @@ -9,6 +9,7 @@ use lsp_types::{ TextDocumentPositionParams, TextEdit, Uri, WorkspaceEdit, WorkspaceFolder, }; use miette::{miette, IntoDiagnostic, Result}; +use nu_glob::Uninterruptible; use nu_protocol::{ engine::{EngineState, StateWorkingSet}, Span, @@ -42,7 +43,7 @@ fn find_nu_scripts_in_folder(folder_uri: &Uri) -> Result { return Err(miette!("\nworkspace folder does not exist.")); } let pattern = format!("{}/**/*.nu", path.to_string_lossy()); - nu_glob::glob(&pattern, None).into_diagnostic() + nu_glob::glob(&pattern, Uninterruptible).into_diagnostic() } impl LanguageServer { diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml index 831741464a..e6f85a8558 100644 --- a/crates/nu-protocol/Cargo.toml +++ b/crates/nu-protocol/Cargo.toml @@ -17,6 +17,7 @@ workspace = true [dependencies] nu-utils = { path = "../nu-utils", version = "0.103.1", default-features = false } +nu-glob = { path = "../nu-glob", version = "0.103.1" } nu-path = { path = "../nu-path", version = "0.103.1" } nu-system = { path = "../nu-system", version = "0.103.1" } nu-derive-value = { path = "../nu-derive-value", version = "0.103.1" } diff --git a/crates/nu-protocol/src/pipeline/signals.rs b/crates/nu-protocol/src/pipeline/signals.rs index f712f1e7a8..1d60ac103c 100644 --- a/crates/nu-protocol/src/pipeline/signals.rs +++ b/crates/nu-protocol/src/pipeline/signals.rs @@ -1,11 +1,11 @@ use crate::{ShellError, Span}; +use nu_glob::Interruptible; +use serde::{Deserialize, Serialize}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, }; -use serde::{Deserialize, Serialize}; - /// Used to check for signals to suspend or terminate the execution of Nushell code. /// /// For now, this struct only supports interruption (ctrl+c or SIGINT). @@ -84,6 +84,13 @@ impl Signals { } } +impl Interruptible for Signals { + #[inline] + fn interrupted(&self) -> bool { + self.interrupted() + } +} + /// The types of things that can be signaled. It's anticipated this will change as we learn more /// about how we'd like signals to be handled. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/nu-test-support/src/playground/play.rs b/crates/nu-test-support/src/playground/play.rs index 60b6c7f9f5..5ff1fd5977 100644 --- a/crates/nu-test-support/src/playground/play.rs +++ b/crates/nu-test-support/src/playground/play.rs @@ -1,6 +1,6 @@ use super::Director; use crate::fs::{self, Stub}; -use nu_glob::glob; +use nu_glob::{glob, Uninterruptible}; #[cfg(not(target_arch = "wasm32"))] use nu_path::Path; use nu_path::{AbsolutePath, AbsolutePathBuf}; @@ -231,7 +231,7 @@ impl Playground<'_> { } pub fn glob_vec(pattern: &str) -> Vec { - let glob = glob(pattern, None); + let glob = glob(pattern, Uninterruptible); glob.expect("invalid pattern") .map(|path| { From 2ea2a904e8d3cae4c022687a79589f9228d96a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= <96702577+LoicRiegel@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:35:50 +0100 Subject: [PATCH 47/59] Math commands can work with bounded ranges and produce list of numbers (#15319) No associated issue, but follows up #15135. See also discussion on [discord](https://discord.com/channels/601130461678272522/1349139634281513093/1349139639356624966) with @sholderbach # Description ### Math commands `range -> list` This enables the following math commands: - abs - ceil - floor - log - round to work with ranges. When a range is given, the command will apply the command on each item of the range, thus producing a list of number as output. Example ![image](https://github.com/user-attachments/assets/cff12724-5b26-4dbb-a979-a91c1b5652fc) The commands still do not work work with unbounded ranges: ![image](https://github.com/user-attachments/assets/40c766a8-763f-461d-971b-2d58d11fc3a6) And I left out the "mode" command because I think it does not make sense to use it on ranges... ### Math commands `range -> number` This was the topic of my previous PR, but for whatever reason I didn't do `math variance` and `math stddev`. I had to use `input.try_expand_range` to convert the range into a list before computing the variance/stddev. ![image](https://github.com/user-attachments/assets/803954e7-1c2a-4c86-8b16-e16518131138) And same, does not work in infinite ranges: ![image](https://github.com/user-attachments/assets/8bfaae2b-34cc-453d-8764-e42c815d28d3) ### Also done: - find link in documentation # User-Facing Changes - Command signatures changes - ability to use some commands with unbounded ranges - ability to use variance and stddev with bounded ranges # Tests + Formatting Cargo fmt and clippy OK Tests OK # After Submitting I guess nothing, or maybe release notes? --- crates/nu-command/src/math/abs.rs | 29 +++++++++++++++++ crates/nu-command/src/math/ceil.rs | 29 +++++++++++++++++ crates/nu-command/src/math/floor.rs | 29 +++++++++++++++++ crates/nu-command/src/math/log.rs | 31 +++++++++++++++++++ crates/nu-command/src/math/mode.rs | 6 ++-- crates/nu-command/src/math/round.rs | 29 +++++++++++++++++ crates/nu-command/src/math/sqrt.rs | 29 +++++++++++++++++ crates/nu-command/src/math/stddev.rs | 25 +++++++++++++++ crates/nu-command/src/math/variance.rs | 25 +++++++++++++++ crates/nu-command/tests/commands/math/abs.rs | 14 +++++++-- crates/nu-command/tests/commands/math/ceil.rs | 14 +++++++-- .../nu-command/tests/commands/math/floor.rs | 12 +++++-- crates/nu-command/tests/commands/math/log.rs | 14 +++++++-- .../nu-command/tests/commands/math/round.rs | 14 +++++++-- crates/nu-command/tests/commands/math/sqrt.rs | 12 +++++-- .../nu-command/tests/commands/math/stddev.rs | 12 +++++-- .../tests/commands/math/variance.rs | 12 +++++-- devdocs/README.md | 2 +- 18 files changed, 314 insertions(+), 24 deletions(-) diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index 4fae0633c8..5ebae80e2f 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct MathAbs; @@ -21,6 +23,7 @@ impl Command for MathAbs { Type::List(Box::new(Type::Duration)), Type::List(Box::new(Type::Duration)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .category(Category::Math) @@ -46,6 +49,19 @@ impl Command for MathAbs { input: PipelineData, ) -> Result { let head = call.head; + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map(move |value| abs_helper(value, head), engine_state.signals()) } @@ -56,6 +72,19 @@ impl Command for MathAbs { input: PipelineData, ) -> Result { let head = call.head; + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| abs_helper(value, head), working_set.permanent().signals(), diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index 5867f21bca..585b12aa62 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct MathCeil; @@ -16,6 +18,7 @@ impl Command for MathCeil { Type::List(Box::new(Type::Number)), Type::List(Box::new(Type::Int)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .category(Category::Math) @@ -45,6 +48,19 @@ impl Command for MathCeil { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map(move |value| operate(value, head), engine_state.signals()) } @@ -59,6 +75,19 @@ impl Command for MathCeil { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| operate(value, head), working_set.permanent().signals(), diff --git a/crates/nu-command/src/math/floor.rs b/crates/nu-command/src/math/floor.rs index 2bc705f926..73760a390a 100644 --- a/crates/nu-command/src/math/floor.rs +++ b/crates/nu-command/src/math/floor.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct MathFloor; @@ -16,6 +18,7 @@ impl Command for MathFloor { Type::List(Box::new(Type::Number)), Type::List(Box::new(Type::Int)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .category(Category::Math) @@ -45,6 +48,19 @@ impl Command for MathFloor { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map(move |value| operate(value, head), engine_state.signals()) } @@ -59,6 +75,19 @@ impl Command for MathFloor { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| operate(value, head), working_set.permanent().signals(), diff --git a/crates/nu-command/src/math/log.rs b/crates/nu-command/src/math/log.rs index 79eed71640..eff8c583df 100644 --- a/crates/nu-command/src/math/log.rs +++ b/crates/nu-command/src/math/log.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; use nu_protocol::Signals; #[derive(Clone)] @@ -22,6 +24,7 @@ impl Command for MathLog { Type::List(Box::new(Type::Number)), Type::List(Box::new(Type::Float)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .category(Category::Math) @@ -46,7 +49,21 @@ impl Command for MathLog { call: &Call, input: PipelineData, ) -> Result { + let head = call.head; let base: Spanned = call.req(engine_state, stack, 0)?; + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } log(base, call.head, input, engine_state.signals()) } @@ -56,7 +73,21 @@ impl Command for MathLog { call: &Call, input: PipelineData, ) -> Result { + let head = call.head; let base: Spanned = call.req_const(working_set, 0)?; + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } log(base, call.head, input, working_set.permanent().signals()) } diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index 5183a855a9..e9e827ad83 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -110,7 +110,7 @@ impl Command for MathMode { } } -pub fn mode(values: &[Value], _span: Span, head: Span) -> Result { +pub fn mode(values: &[Value], span: Span, head: Span) -> Result { //In e-q, Value doesn't implement Hash or Eq, so we have to get the values inside // But f64 doesn't implement Hash, so we get the binary representation to use as // key in the HashMap @@ -130,11 +130,11 @@ pub fn mode(values: &[Value], _span: Span, head: Span) -> Result Err(*error.clone()), - other => Err(ShellError::UnsupportedInput { + _ => Err(ShellError::UnsupportedInput { msg: "Unable to give a result with this input".to_string(), input: "value originates from here".into(), msg_span: head, - input_span: other.span(), + input_span: span, }), }) .collect::, ShellError>>()?; diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index 558715e675..aa04839e32 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct MathRound; @@ -16,6 +18,7 @@ impl Command for MathRound { Type::List(Box::new(Type::Number)), Type::List(Box::new(Type::Number)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .named( @@ -52,6 +55,19 @@ impl Command for MathRound { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| operate(value, head, precision_param), engine_state.signals(), @@ -70,6 +86,19 @@ impl Command for MathRound { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| operate(value, head, precision_param), working_set.permanent().signals(), diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index 38b2a4d800..7bb5ccc78e 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -1,4 +1,6 @@ +use crate::math::utils::ensure_bounded; use nu_engine::command_prelude::*; +use nu_protocol::Range; #[derive(Clone)] pub struct MathSqrt; @@ -16,6 +18,7 @@ impl Command for MathSqrt { Type::List(Box::new(Type::Number)), Type::List(Box::new(Type::Float)), ), + (Type::Range, Type::List(Box::new(Type::Number))), ]) .allow_variants_without_examples(true) .category(Category::Math) @@ -45,6 +48,19 @@ impl Command for MathSqrt { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map(move |value| operate(value, head), engine_state.signals()) } @@ -59,6 +75,19 @@ impl Command for MathSqrt { if matches!(input, PipelineData::Empty) { return Err(ShellError::PipelineEmpty { dst_span: head }); } + if let PipelineData::Value( + Value::Range { + ref val, + internal_span, + }, + .., + ) = input + { + match &**val { + Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?, + Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?, + } + } input.map( move |value| operate(value, head), working_set.permanent().signals(), diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index 051f7d02d7..2987949e05 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -14,6 +14,7 @@ impl Command for MathStddev { Signature::build("math stddev") .input_output_types(vec![ (Type::List(Box::new(Type::Number)), Type::Number), + (Type::Range, Type::Number), (Type::table(), Type::record()), (Type::record(), Type::record()), ]) @@ -53,6 +54,18 @@ impl Command for MathStddev { input: PipelineData, ) -> Result { let sample = call.has_flag(engine_state, stack, "sample")?; + let name = call.head; + let span = input.span().unwrap_or(name); + let input: PipelineData = match input.try_expand_range() { + Err(_) => { + return Err(ShellError::IncorrectValue { + msg: "Range must be bounded".to_string(), + val_span: span, + call_span: name, + }); + } + Ok(val) => val, + }; run_with_function(call, input, compute_stddev(sample)) } @@ -63,6 +76,18 @@ impl Command for MathStddev { input: PipelineData, ) -> Result { let sample = call.has_flag_const(working_set, "sample")?; + let name = call.head; + let span = input.span().unwrap_or(name); + let input: PipelineData = match input.try_expand_range() { + Err(_) => { + return Err(ShellError::IncorrectValue { + msg: "Range must be bounded".to_string(), + val_span: span, + call_span: name, + }); + } + Ok(val) => val, + }; run_with_function(call, input, compute_stddev(sample)) } diff --git a/crates/nu-command/src/math/variance.rs b/crates/nu-command/src/math/variance.rs index b221d92746..92712872f5 100644 --- a/crates/nu-command/src/math/variance.rs +++ b/crates/nu-command/src/math/variance.rs @@ -13,6 +13,7 @@ impl Command for MathVariance { Signature::build("math variance") .input_output_types(vec![ (Type::List(Box::new(Type::Number)), Type::Number), + (Type::Range, Type::Number), (Type::table(), Type::record()), (Type::record(), Type::record()), ]) @@ -45,6 +46,18 @@ impl Command for MathVariance { input: PipelineData, ) -> Result { let sample = call.has_flag(engine_state, stack, "sample")?; + let name = call.head; + let span = input.span().unwrap_or(name); + let input: PipelineData = match input.try_expand_range() { + Err(_) => { + return Err(ShellError::IncorrectValue { + msg: "Range must be bounded".to_string(), + val_span: span, + call_span: name, + }); + } + Ok(val) => val, + }; run_with_function(call, input, compute_variance(sample)) } @@ -55,6 +68,18 @@ impl Command for MathVariance { input: PipelineData, ) -> Result { let sample = call.has_flag_const(working_set, "sample")?; + let name = call.head; + let span = input.span().unwrap_or(name); + let input: PipelineData = match input.try_expand_range() { + Err(_) => { + return Err(ShellError::IncorrectValue { + msg: "Range must be bounded".to_string(), + val_span: span, + call_span: name, + }); + } + Ok(val) => val, + }; run_with_function(call, input, compute_variance(sample)) } diff --git a/crates/nu-command/tests/commands/math/abs.rs b/crates/nu-command/tests/commands/math/abs.rs index de5c7551aa..4ddafd5bb0 100644 --- a/crates/nu-command/tests/commands/math/abs.rs +++ b/crates/nu-command/tests/commands/math/abs.rs @@ -7,8 +7,16 @@ fn const_abs() { } #[test] -fn cannot_abs_range() { - let actual = nu!("0..5 | math abs"); +fn can_abs_range_into_list() { + let actual = nu!("-1.5..-10.5 | math abs"); + let expected = nu!("1.5..10.5"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_abs_infinite_range() { + let actual = nu!("0.. | math abs"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/ceil.rs b/crates/nu-command/tests/commands/math/ceil.rs index f9c753d1dd..e7377efec4 100644 --- a/crates/nu-command/tests/commands/math/ceil.rs +++ b/crates/nu-command/tests/commands/math/ceil.rs @@ -7,8 +7,16 @@ fn const_ceil() { } #[test] -fn cannot_ceil_range() { - let actual = nu!("0..5 | math ceil"); +fn can_ceil_range_into_list() { + let actual = nu!("(1.8)..(3.8) | math ceil"); + let expected = nu!("[2 3 4]"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_ceil_infinite_range() { + let actual = nu!("0.. | math ceil"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/floor.rs b/crates/nu-command/tests/commands/math/floor.rs index 5517233caa..0cf2a47946 100644 --- a/crates/nu-command/tests/commands/math/floor.rs +++ b/crates/nu-command/tests/commands/math/floor.rs @@ -7,8 +7,16 @@ fn const_floor() { } #[test] -fn cannot_floor_range() { +fn can_floor_range_into_list() { + let actual = nu!("(1.8)..(3.8) | math floor"); + let expected = nu!("[1 2 3]"); + + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_floor_infinite_range() { let actual = nu!("0.. | math floor"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/log.rs b/crates/nu-command/tests/commands/math/log.rs index db69378e41..23d6abd7cb 100644 --- a/crates/nu-command/tests/commands/math/log.rs +++ b/crates/nu-command/tests/commands/math/log.rs @@ -7,8 +7,16 @@ fn const_log() { } #[test] -fn cannot_log_range() { - let actual = nu!("0.. | math log 2"); +fn can_log_range_into_list() { + let actual = nu!("1..5 | math log 2"); + let expected = nu!("[1 2 3 4 5] | math log 2"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_log_infinite_range() { + let actual = nu!("1.. | math log 2"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/round.rs b/crates/nu-command/tests/commands/math/round.rs index 2c3badad5e..70b7567354 100644 --- a/crates/nu-command/tests/commands/math/round.rs +++ b/crates/nu-command/tests/commands/math/round.rs @@ -42,8 +42,16 @@ fn const_round() { } #[test] -fn cannot_round_infinite_range() { - let actual = nu!("0..5 | math round"); +fn can_round_range_into_list() { + let actual = nu!("(1.0)..(1.2)..(2.0) | math round"); + let expected = nu!("[1 1 1 2 2 2]"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_round_infinite_range() { + let actual = nu!("0.. | math round"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/sqrt.rs b/crates/nu-command/tests/commands/math/sqrt.rs index 9f5cc55f88..3da12fab7c 100644 --- a/crates/nu-command/tests/commands/math/sqrt.rs +++ b/crates/nu-command/tests/commands/math/sqrt.rs @@ -28,8 +28,16 @@ fn const_sqrt() { } #[test] -fn cannot_sqrt_range() { +fn can_sqrt_range() { let actual = nu!("0..5 | math sqrt"); + let expected = nu!("[0 1 2 3 4 5] | math sqrt"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_sqrt_infinite_range() { + let actual = nu!("0.. | math sqrt"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/stddev.rs b/crates/nu-command/tests/commands/math/stddev.rs index f1688c2d7a..c8398d5637 100644 --- a/crates/nu-command/tests/commands/math/stddev.rs +++ b/crates/nu-command/tests/commands/math/stddev.rs @@ -7,8 +7,16 @@ fn const_avg() { } #[test] -fn cannot_stddev_range() { +fn can_stddev_range() { let actual = nu!("0..5 | math stddev"); + let expected = nu!("[0 1 2 3 4 5] | math stddev"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_stddev_infinite_range() { + let actual = nu!("0.. | math stddev"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/crates/nu-command/tests/commands/math/variance.rs b/crates/nu-command/tests/commands/math/variance.rs index 1573a131bb..b31d75e148 100644 --- a/crates/nu-command/tests/commands/math/variance.rs +++ b/crates/nu-command/tests/commands/math/variance.rs @@ -7,8 +7,16 @@ fn const_variance() { } #[test] -fn cannot_variance_range() { +fn can_variance_range() { let actual = nu!("0..5 | math variance"); + let expected = nu!("[0 1 2 3 4 5] | math variance"); - assert!(actual.err.contains("nu::parser::input_type_mismatch")); + assert_eq!(actual.out, expected.out); +} + +#[test] +fn cannot_variance_infinite_range() { + let actual = nu!("0.. | math variance"); + + assert!(actual.err.contains("nu::shell::incorrect_value")); } diff --git a/devdocs/README.md b/devdocs/README.md index fe558d5e65..08a6a29dc5 100644 --- a/devdocs/README.md +++ b/devdocs/README.md @@ -9,4 +9,4 @@ A complementary (currently stale) resource has been the [Nushell contributor boo - [Developer FAQ](FAQ.md) - [How to/SOPs](HOWTOS.md) - [Platform support policy](PLATFORM_SUPPORT.md) -- [Our Rust style](devdocs/rust_style.md) +- [Our Rust style](rust_style.md) From 7a6cfa24fc9975fcbbb501e2c507742f7ab985d0 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Thu, 20 Mar 2025 17:50:36 +0100 Subject: [PATCH 48/59] Fix `to nuon --serialize` of closure (#15357) # Description Closes #15351 Adds quotes that were missed in #14698 with the proper escaping. # User-Facing Changes `to nuon --serialize` will now produce a quoted string instead of illegal nuon when given a closure # Tests + Formatting Reenable the `to nuon` rejection of closures in the base state test. Added test for quoting. --- .../nu-command/tests/format_conversions/nuon.rs | 15 +++++++++++++-- crates/nuon/src/to.rs | 4 +++- tests/eval/mod.rs | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/tests/format_conversions/nuon.rs b/crates/nu-command/tests/format_conversions/nuon.rs index ca23e6823b..1fcd1983e4 100644 --- a/crates/nu-command/tests/format_conversions/nuon.rs +++ b/crates/nu-command/tests/format_conversions/nuon.rs @@ -307,7 +307,6 @@ fn from_nuon_datetime() { } #[test] -#[ignore] fn to_nuon_errs_on_closure() { let actual = nu!(pipeline( r#" @@ -316,7 +315,19 @@ fn to_nuon_errs_on_closure() { "# )); - assert!(actual.err.contains("can't convert closure to NUON")); + assert!(actual.err.contains("not deserializable")); +} + +#[test] +fn to_nuon_closure_coerced_to_quoted_string() { + let actual = nu!(pipeline( + r#" + {|| to nuon} + | to nuon --serialize + "# + )); + + assert_eq!(actual.out, "\"{|| to nuon}\""); } #[test] diff --git a/crates/nuon/src/to.rs b/crates/nuon/src/to.rs index e7ed06c461..fae454cd9a 100644 --- a/crates/nuon/src/to.rs +++ b/crates/nuon/src/to.rs @@ -99,7 +99,9 @@ fn value_to_string( } Value::Closure { val, .. } => { if serialize_types { - Ok(val.coerce_into_string(engine_state, span)?.to_string()) + Ok(escape_quote_string( + &val.coerce_into_string(engine_state, span)?, + )) } else { Err(ShellError::UnsupportedInput { msg: "closures are currently not deserializable (use --serialize to serialize as a string)".into(), diff --git a/tests/eval/mod.rs b/tests/eval/mod.rs index db954df231..736d4a1af9 100644 --- a/tests/eval/mod.rs +++ b/tests/eval/mod.rs @@ -108,7 +108,7 @@ fn literal_closure() { #[test] fn literal_closure_to_nuon() { - test_eval("{||} | to nuon --serialize", Eq("{||}")) + test_eval("{||} | to nuon --serialize", Eq("\"{||}\"")) } #[test] From dd56c813f99a47541220d5e04044277930571c2a Mon Sep 17 00:00:00 2001 From: Solomon Date: Thu, 20 Mar 2025 18:20:28 +0000 Subject: [PATCH 49/59] preserve variable capture spans in blocks (#15334) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #15160 # User-Facing Changes Certain "variable not found" errors no longer highlight the surrounding block. Before: ```nushell do { match foo { _ => $in } } Error: nu::shell::variable_not_found × Variable not found ╭─[entry #1:1:1] 1 │ ╭─▶ do { 2 │ │ match foo { 3 │ │ _ => $in 4 │ │ } 5 │ ├─▶ } · ╰──── variable not found ``` After: ```nushell Error: nu::shell::variable_not_found × Variable not found ╭─[entry #1:3:10] 2 │ match foo { 3 │ _ => $in · ─┬─ · ╰── variable not found ``` --- crates/nu-engine/src/eval.rs | 10 +++++----- crates/nu-engine/src/eval_ir.rs | 2 +- crates/nu-parser/src/parser.rs | 9 ++++----- crates/nu-protocol/src/ast/block.rs | 2 +- crates/nu-protocol/src/ast/expression.rs | 5 ++++- crates/nu-protocol/src/engine/stack.rs | 4 ++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 01f7b69f7a..41d39241f8 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -642,17 +642,17 @@ impl Eval for EvalRuntime { .get_block(block_id) .captures .iter() - .map(|&id| { + .map(|(id, span)| { stack - .get_var(id, span) + .get_var(*id, *span) .or_else(|_| { engine_state - .get_var(id) + .get_var(*id) .const_val .clone() - .ok_or(ShellError::VariableNotFoundAtRuntime { span }) + .ok_or(ShellError::VariableNotFoundAtRuntime { span: *span }) }) - .map(|var| (id, var)) + .map(|var| (*id, var)) }) .collect::>()?; diff --git a/crates/nu-engine/src/eval_ir.rs b/crates/nu-engine/src/eval_ir.rs index 6ca4d2e8ca..20a0bda94d 100644 --- a/crates/nu-engine/src/eval_ir.rs +++ b/crates/nu-engine/src/eval_ir.rs @@ -857,7 +857,7 @@ fn literal_value( let captures = block .captures .iter() - .map(|var_id| get_var(ctx, *var_id, span).map(|val| (*var_id, val))) + .map(|(var_id, span)| get_var(ctx, *var_id, *span).map(|val| (*var_id, val))) .collect::, ShellError>>()?; Value::closure( Closure { diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 715afb5bad..ef181a6a3f 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -6589,9 +6589,9 @@ pub fn discover_captures_in_expr( None => { let block = working_set.get_block(block_id); if !block.captures.is_empty() { - for capture in &block.captures { + for (capture, span) in &block.captures { if !seen.contains(capture) { - output.push((*capture, call.head)); + output.push((*capture, *span)); } } } else { @@ -6905,8 +6905,7 @@ pub fn parse( &mut captures, ) { Ok(_) => { - Arc::make_mut(&mut output).captures = - captures.into_iter().map(|(var_id, _)| var_id).collect(); + Arc::make_mut(&mut output).captures = captures; } Err(err) => working_set.error(err), } @@ -6961,7 +6960,7 @@ pub fn parse( && block_id.get() >= working_set.permanent_state.num_blocks() { let block = working_set.get_block_mut(block_id); - block.captures = captures.into_iter().map(|(var_id, _)| var_id).collect(); + block.captures = captures; } } diff --git a/crates/nu-protocol/src/ast/block.rs b/crates/nu-protocol/src/ast/block.rs index a6e640cc15..ab603da0da 100644 --- a/crates/nu-protocol/src/ast/block.rs +++ b/crates/nu-protocol/src/ast/block.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; pub struct Block { pub signature: Box, pub pipelines: Vec, - pub captures: Vec, + pub captures: Vec<(VarId, Span)>, pub redirect_env: bool, /// The block compiled to IR instructions. Not available for subexpressions. pub ir_block: Option, diff --git a/crates/nu-protocol/src/ast/expression.rs b/crates/nu-protocol/src/ast/expression.rs index 7d08f62533..5ffa3aab8b 100644 --- a/crates/nu-protocol/src/ast/expression.rs +++ b/crates/nu-protocol/src/ast/expression.rs @@ -111,7 +111,10 @@ impl Expression { Expr::UnaryNot(expr) => expr.has_in_variable(working_set), Expr::Block(block_id) | Expr::Closure(block_id) => { let block = working_set.get_block(*block_id); - block.captures.contains(&IN_VARIABLE_ID) + block + .captures + .iter() + .any(|(var_id, _)| var_id == &IN_VARIABLE_ID) || block .pipelines .iter() diff --git a/crates/nu-protocol/src/engine/stack.rs b/crates/nu-protocol/src/engine/stack.rs index 0e8df6b654..2c6422f503 100644 --- a/crates/nu-protocol/src/engine/stack.rs +++ b/crates/nu-protocol/src/engine/stack.rs @@ -322,12 +322,12 @@ impl Stack { } } - pub fn gather_captures(&self, engine_state: &EngineState, captures: &[VarId]) -> Stack { + pub fn gather_captures(&self, engine_state: &EngineState, captures: &[(VarId, Span)]) -> Stack { let mut vars = Vec::with_capacity(captures.len()); let fake_span = Span::new(0, 0); - for capture in captures { + for (capture, _) in captures { // Note: this assumes we have calculated captures correctly and that commands // that take in a var decl will manually set this into scope when running the blocks if let Ok(value) = self.get_var(*capture, fake_span) { From 3fe355c4a64a76fcf7ed4669c1175c084875b4d9 Mon Sep 17 00:00:00 2001 From: Solomon Date: Thu, 20 Mar 2025 18:51:22 +0000 Subject: [PATCH 50/59] enable streaming in `random` `binary`/`chars` (#15361) # User-Facing Changes - `random binary` and `random chars` now stream, reducing memory usage and allowing interruption with ctrl-c --- crates/nu-command/src/random/binary.rs | 14 +++--- crates/nu-command/src/random/byte_stream.rs | 49 +++++++++++++++++++++ crates/nu-command/src/random/chars.rs | 22 +++------ crates/nu-command/src/random/mod.rs | 1 + 4 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 crates/nu-command/src/random/byte_stream.rs diff --git a/crates/nu-command/src/random/binary.rs b/crates/nu-command/src/random/binary.rs index 47e6429eba..663affbc12 100644 --- a/crates/nu-command/src/random/binary.rs +++ b/crates/nu-command/src/random/binary.rs @@ -1,5 +1,5 @@ +use super::byte_stream::{random_byte_stream, RandomDistribution}; use nu_engine::command_prelude::*; -use rand::{thread_rng, RngCore}; #[derive(Clone)] pub struct RandomBinary; @@ -57,12 +57,12 @@ impl Command for RandomBinary { }), }?; - let mut rng = thread_rng(); - - let mut out = vec![0u8; length]; - rng.fill_bytes(&mut out); - - Ok(Value::binary(out, call.head).into_pipeline_data()) + Ok(random_byte_stream( + RandomDistribution::Binary, + length, + call.head, + engine_state.signals().clone(), + )) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/random/byte_stream.rs b/crates/nu-command/src/random/byte_stream.rs new file mode 100644 index 0000000000..baff8fbc6c --- /dev/null +++ b/crates/nu-command/src/random/byte_stream.rs @@ -0,0 +1,49 @@ +use nu_engine::command_prelude::*; +use nu_protocol::Signals; +use rand::{ + distributions::{Alphanumeric, Standard}, + thread_rng, Rng, +}; + +pub(super) enum RandomDistribution { + Binary, + Alphanumeric, +} + +pub(super) fn random_byte_stream( + distribution: RandomDistribution, + length: usize, + span: Span, + signals: Signals, +) -> PipelineData { + let stream_type = match distribution { + RandomDistribution::Binary => ByteStreamType::Binary, + RandomDistribution::Alphanumeric => ByteStreamType::String, + }; + + const OUTPUT_CHUNK_SIZE: usize = 8192; + let mut remaining_bytes = length; + PipelineData::ByteStream( + ByteStream::from_fn(span, signals.clone(), stream_type, move |out| { + if remaining_bytes == 0 || signals.interrupted() { + return Ok(false); + } + + let bytes_to_write = std::cmp::min(remaining_bytes, OUTPUT_CHUNK_SIZE); + + let rng = thread_rng(); + let byte_iter: Box> = match distribution { + RandomDistribution::Binary => Box::new(rng.sample_iter(Standard)), + RandomDistribution::Alphanumeric => Box::new(rng.sample_iter(Alphanumeric)), + }; + out.extend(byte_iter.take(bytes_to_write)); + + remaining_bytes -= bytes_to_write; + + Ok(true) + }) + .with_known_size(Some(length as u64)), + None, + ) + .with_span(span) +} diff --git a/crates/nu-command/src/random/chars.rs b/crates/nu-command/src/random/chars.rs index 5ef76603b7..ad9d8ac2ac 100644 --- a/crates/nu-command/src/random/chars.rs +++ b/crates/nu-command/src/random/chars.rs @@ -1,8 +1,5 @@ +use super::byte_stream::{random_byte_stream, RandomDistribution}; use nu_engine::command_prelude::*; -use rand::{ - distributions::{Alphanumeric, Distribution}, - thread_rng, -}; const DEFAULT_CHARS_LENGTH: usize = 25; @@ -71,7 +68,6 @@ fn chars( stack: &mut Stack, call: &Call, ) -> Result { - let span = call.head; let length: Option = call.get_flag(engine_state, stack, "length")?; let length = if let Some(length_val) = length { match length_val { @@ -97,17 +93,11 @@ fn chars( DEFAULT_CHARS_LENGTH }; - let mut rng = thread_rng(); - - let random_string = Alphanumeric - .sample_iter(&mut rng) - .take(length) - .map(char::from) - .collect::(); - - Ok(PipelineData::Value( - Value::string(random_string, span), - None, + Ok(random_byte_stream( + RandomDistribution::Alphanumeric, + length, + call.head, + engine_state.signals().clone(), )) } diff --git a/crates/nu-command/src/random/mod.rs b/crates/nu-command/src/random/mod.rs index 43c8af862f..c4b635449b 100644 --- a/crates/nu-command/src/random/mod.rs +++ b/crates/nu-command/src/random/mod.rs @@ -1,5 +1,6 @@ mod binary; mod bool; +mod byte_stream; mod chars; mod dice; mod float; From 5832823dff8e7286c15d011c7a121921eb277f65 Mon Sep 17 00:00:00 2001 From: zc he Date: Fri, 21 Mar 2025 19:35:18 +0800 Subject: [PATCH 51/59] fix: flatten of empty closures (#15374) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #15373 # Description Now `ast -f "{||}"` will return ``` ╭─content─┬─────shape─────┬─────span──────╮ │ {||} │ shape_closure │ ╭───────┬───╮ │ │ │ │ │ start │ 0 │ │ │ │ │ │ end │ 4 │ │ │ │ │ ╰───────┴───╯ │ ╰─────────┴───────────────┴───────────────╯ ``` Similar to those of `ast -f "[]"`/`ast -f "{}"` # User-Facing Changes # Tests + Formatting I didn't find the right place to do the test, except for the examples of `ast` command. # After Submitting --- crates/nu-parser/src/flatten.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/nu-parser/src/flatten.rs b/crates/nu-parser/src/flatten.rs index 46cf901f9a..c49b1720df 100644 --- a/crates/nu-parser/src/flatten.rs +++ b/crates/nu-parser/src/flatten.rs @@ -232,7 +232,8 @@ fn flatten_expression_into( None } } else { - None + // for empty closures + Some((outer_span, FlatShape::Closure)) }; output.extend(flattened); From 7c160725ede01b2f044b1821ad53be72d8ae7d77 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:36:21 -0400 Subject: [PATCH 52/59] Rename user-facing 'date' to 'datetime' (#15264) We only have one valid `datetime` type, but the string representation of that type was `date`. This PR updates the string representation of the `datetime` type to be `datetime` and updates other affected dependencies: * A `describe` example that used `date` * The style computer automatically recognized the new change, but also changed the default `date: purple` to `datetime: purple`. * Likewise, changed the `default_config.nu` to populate `$env.config.color_config.datetime` * Likewise, the dark and light themes in `std/config` * Updates tests * Unrelated, but changed the `into value` error messages to use *"datetime"* if there's an issue. Fixes #9916 and perhaps others. ## Breaking Changes: * Code that expected `describe` to return a `date` will now return a `datetime` * User configs and themes that override `$env.config.color_config.date` will need to be updated to use `datetime` --- crates/nu-cmd-lang/src/core_commands/describe.rs | 2 +- crates/nu-color-config/src/style_computer.rs | 2 +- crates/nu-command/src/conversions/into/value.rs | 6 +++--- crates/nu-command/tests/commands/table.rs | 8 ++++---- crates/nu-command/tests/format_conversions/nuon.rs | 2 +- crates/nu-protocol/src/ty.rs | 4 ++-- crates/nu-protocol/src/value/mod.rs | 2 +- crates/nu-std/std/config/mod.nu | 4 ++-- crates/nu-utils/src/default_files/default_config.nu | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/nu-cmd-lang/src/core_commands/describe.rs b/crates/nu-cmd-lang/src/core_commands/describe.rs index 375a840b16..b3f7b50611 100644 --- a/crates/nu-cmd-lang/src/core_commands/describe.rs +++ b/crates/nu-cmd-lang/src/core_commands/describe.rs @@ -103,7 +103,7 @@ impl Command for Describe { "category" => Value::test_string("default"), )), )), - "first_commit" => Value::test_string("date"), + "first_commit" => Value::test_string("datetime"), "my_duration" => Value::test_string("duration"), )), ))), diff --git a/crates/nu-color-config/src/style_computer.rs b/crates/nu-color-config/src/style_computer.rs index b055a6a46c..af467f31db 100644 --- a/crates/nu-color-config/src/style_computer.rs +++ b/crates/nu-color-config/src/style_computer.rs @@ -120,7 +120,7 @@ impl<'a> StyleComputer<'a> { ("int".to_string(), ComputableStyle::Static(Color::White.normal())), ("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())), ("duration".to_string(), ComputableStyle::Static(Color::White.normal())), - ("date".to_string(), ComputableStyle::Static(Color::Purple.normal())), + ("datetime".to_string(), ComputableStyle::Static(Color::Purple.normal())), ("range".to_string(), ComputableStyle::Static(Color::White.normal())), ("float".to_string(), ComputableStyle::Static(Color::White.normal())), ("string".to_string(), ComputableStyle::Static(Color::White.normal())), diff --git a/crates/nu-command/src/conversions/into/value.rs b/crates/nu-command/src/conversions/into/value.rs index de371e27b9..eb2cf3a278 100644 --- a/crates/nu-command/src/conversions/into/value.rs +++ b/crates/nu-command/src/conversions/into/value.rs @@ -208,7 +208,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result Result Result String::from("closure"), Type::Bool => String::from("bool"), Type::CellPath => String::from("cell-path"), - Type::Date => String::from("date"), + Type::Date => String::from("datetime"), Type::Duration => String::from("duration"), Type::Filesize => String::from("filesize"), Type::Float => String::from("float"), @@ -162,7 +162,7 @@ impl Display for Type { Type::Closure => write!(f, "closure"), Type::Bool => write!(f, "bool"), Type::CellPath => write!(f, "cell-path"), - Type::Date => write!(f, "date"), + Type::Date => write!(f, "datetime"), Type::Duration => write!(f, "duration"), Type::Filesize => write!(f, "filesize"), Type::Float => write!(f, "float"), diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 428031c48f..4969daf28e 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -329,7 +329,7 @@ impl Value { if let Value::Date { val, .. } = self { Ok(*val) } else { - self.cant_convert_to("date") + self.cant_convert_to("datetime") } } diff --git a/crates/nu-std/std/config/mod.nu b/crates/nu-std/std/config/mod.nu index 9b00db60db..ce4549d3be 100644 --- a/crates/nu-std/std/config/mod.nu +++ b/crates/nu-std/std/config/mod.nu @@ -13,7 +13,7 @@ export def dark-theme [] { int: white filesize: cyan duration: white - date: purple + datetime: purple range: white float: white string: white @@ -81,7 +81,7 @@ export def light-theme [] { int: dark_gray filesize: cyan_bold duration: dark_gray - date: purple + datetime: purple range: dark_gray float: dark_gray string: dark_gray diff --git a/crates/nu-utils/src/default_files/default_config.nu b/crates/nu-utils/src/default_files/default_config.nu index b7cc5675fc..40647d49b8 100644 --- a/crates/nu-utils/src/default_files/default_config.nu +++ b/crates/nu-utils/src/default_files/default_config.nu @@ -10,7 +10,7 @@ $env.config.color_config = { int: white filesize: cyan duration: white - date: purple + datetime: purple range: white float: white string: white From f33a26123c9d903f6f9e00eb18903d6aed6fad51 Mon Sep 17 00:00:00 2001 From: Firegem Date: Sat, 22 Mar 2025 08:42:20 -0400 Subject: [PATCH 53/59] Fix `path add` bug when given a record (#15379) `path add`, when given a record, sets `$env.PATH` according to the value of the key matching `$nu.os-info.name`. There already existed a check in place to ensure the correct column existed, but it was never reached because of an early error on `path expand`ing `null`. This has been fixed, as well as the out-of-date reference to "darwin" instead of "macos" in the example. # User-Facing Changes `path add` now simply ignores a record that doesn't include a key for the current OS `path add` also will no longer add duplicate paths. --- crates/nu-std/std/util/mod.nu | 52 +++++++++++++++------------- crates/nu-std/tests/test_std_util.nu | 6 ++++ crates/nu-std/tests/test_util.nu | 6 ++++ 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/crates/nu-std/std/util/mod.nu b/crates/nu-std/std/util/mod.nu index c25af22542..3003802d63 100644 --- a/crates/nu-std/std/util/mod.nu +++ b/crates/nu-std/std/util/mod.nu @@ -7,14 +7,14 @@ path add "returned" --ret } } --result [returned bar baz foo fooo] -@example "adding paths based on the operating system" { - path add {linux: "foo", windows: "bar", darwin: "baz"} +@example "adding paths based on $nu.os-info.name" { + path add {linux: "foo", windows: "bar", macos: "baz"} } export def --env "path add" [ - --ret (-r) # return $env.PATH, useful in pipelines to avoid scoping. + --ret (-r) # return $env.PATH, useful in pipelines to avoid scoping. --append (-a) # append to $env.PATH instead of prepending to. - ...paths # the paths to add to $env.PATH. -] { + ...paths: any # the paths to add to $env.PATH. +]: [nothing -> nothing, nothing -> list] { let span = (metadata $paths).span let paths = $paths | flatten @@ -25,34 +25,36 @@ export def --env "path add" [ }} } + for path in $paths { + if ($path | describe -d).type not-in ['string', 'record'] { + error make {msg: 'Invalid input', label: { + text: 'Path must be a string or record', + span: (metadata $path).span + }} + } + } + let path_name = if "PATH" in $env { "PATH" } else { "Path" } let paths = $paths | each {|p| - let p = match ($p | describe | str replace --regex '<.*' '') { - "string" => $p, - "record" => { $p | get --ignore-errors $nu.os-info.name }, + match ($p | describe -d).type { + 'string' => { $p | path expand --no-symlink }, + 'record' => { + if $nu.os-info.name in ($p | columns) { + $p | get $nu.os-info.name | path expand --no-symlink + } + } } - - $p | path expand --no-symlink - } - - if null in $paths or ($paths | is-empty) { - error make {msg: "Empty input", label: { - text: $"Received a record, that does not contain a ($nu.os-info.name) key", - span: $span - }} - } + } | compact load-env {$path_name: ( - $env - | get $path_name - | split row (char esep) - | if $append { append $paths } else { prepend $paths } + $env | get $path_name + | split row (char esep) + | if $append { append $paths } else { prepend $paths } + | uniq )} - if $ret { - $env | get $path_name - } + if $ret { $env | get $path_name } } # The cute and friendly mascot of Nushell :) diff --git a/crates/nu-std/tests/test_std_util.nu b/crates/nu-std/tests/test_std_util.nu index 2b3203d667..40d7945234 100644 --- a/crates/nu-std/tests/test_std_util.nu +++ b/crates/nu-std/tests/test_std_util.nu @@ -39,6 +39,12 @@ def path_add [] { path add $target_paths assert equal (get_path) ([($target_paths | get $nu.os-info.name)] | path expand) + load-env {$path_name: []} + path add {} + assert equal (get_path) [] + + assert error {|| path add 1 } + load-env {$path_name: [$"(["/foo", "/bar"] | path expand | str join (char esep))"]} path add "~/foo" assert equal (get_path) (["~/foo", "/foo", "/bar"] | path expand) diff --git a/crates/nu-std/tests/test_util.nu b/crates/nu-std/tests/test_util.nu index ca99e2f654..97b0fe5d6f 100644 --- a/crates/nu-std/tests/test_util.nu +++ b/crates/nu-std/tests/test_util.nu @@ -39,6 +39,12 @@ def path_add [] { path add $target_paths assert equal (get_path) ([($target_paths | get $nu.os-info.name)] | path expand) + load-env {$path_name: []} + path add {} + assert equal (get_path) ([]) + + assert error {|| path add 1 } + load-env {$path_name: [$"(["/foo", "/bar"] | path expand | str join (char esep))"]} path add "~/foo" assert equal (get_path) (["~/foo", "/foo", "/bar"] | path expand) From 6aed1b42ae395fe6c8a1e42b64652f287ed60d58 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Mon, 24 Mar 2025 08:27:02 -0400 Subject: [PATCH 54/59] Add current exe directory to default `$NU_PLUGIN_DIRS` (#15380) Quality-of-life improvement - Since core plugins are installed into the same directory as the Nushell binary, this simply adds that directory to the default `$NU_PLUGIN_DIRS`. User-facing changes: The default directory for core plugins is automatically added to the `$NU.PLUGIN_DIRS` with no user action necessary. Uses can immediately, out-of-the-box: ```nushell plugin add nu_plugin_polars plugin use polars ``` --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index f514eb47d0..bdebc876f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -167,9 +167,10 @@ fn main() -> Result<()> { ); working_set.set_variable_const_val( var_id, - Value::test_list(vec![Value::test_string( - default_nu_plugin_dirs_path.to_string_lossy(), - )]), + Value::test_list(vec![ + Value::test_string(default_nu_plugin_dirs_path.to_string_lossy()), + Value::test_string(current_exe_directory().to_string_lossy()), + ]), ); engine_state.merge_delta(working_set.render())?; // End: Default NU_LIB_DIRS, NU_PLUGIN_DIRS From bf1f2d5ebdad222f87982f78cc146c8f1f702021 Mon Sep 17 00:00:00 2001 From: zc he Date: Mon, 24 Mar 2025 20:50:38 +0800 Subject: [PATCH 55/59] fix(completion): ls_color for `~/xxx` symlinks (#15403) # Description Get style with expanded real path, so that symlinks get highlighted correctly. # User-Facing Changes Before: image After: image # Tests + Formatting # After Submitting --- .../src/completions/completion_common.rs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 7d4cc670f8..c40a57527b 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -199,10 +199,9 @@ pub fn complete_item( let ls_colors = (engine_state.config.completions.use_ls_colors && engine_state.config.use_ansi_coloring.get(engine_state)) .then(|| { - let ls_colors_env_str = match stack.get_env_var(engine_state, "LS_COLORS") { - Some(v) => env_to_string("LS_COLORS", v, engine_state, stack).ok(), - None => None, - }; + let ls_colors_env_str = stack + .get_env_var(engine_state, "LS_COLORS") + .and_then(|v| env_to_string("LS_COLORS", v, engine_state, stack).ok()); get_ls_colors(ls_colors_env_str) }); @@ -264,15 +263,12 @@ pub fn complete_item( } let is_dir = p.isdir; let path = original_cwd.apply(p, path_separator); + let real_path = expand_to_real_path(&path); + let metadata = std::fs::symlink_metadata(&real_path).ok(); let style = ls_colors.as_ref().map(|lsc| { - lsc.style_for_path_with_metadata( - &path, - std::fs::symlink_metadata(expand_to_real_path(&path)) - .ok() - .as_ref(), - ) - .map(lscolors::Style::to_nu_ansi_term_style) - .unwrap_or_default() + lsc.style_for_path_with_metadata(&real_path, metadata.as_ref()) + .map(lscolors::Style::to_nu_ansi_term_style) + .unwrap_or_default() }); FileSuggestion { span, From e10ac2ede6c0e9bc5654ece342a48ea32acce734 Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 26 Mar 2025 00:40:20 +0800 Subject: [PATCH 56/59] fix: command `open` sets default flags when calling "from xxx" converters (#15383) Fixes #13722 # Description Simple solution: `eval_block` -> `eval_call` with empty arguments # User-Facing Changes Should be none. # Tests + Formatting +1 # After Submitting --- crates/nu-command/src/filesystem/open.rs | 24 +++++++++++++++--------- crates/nu-command/tests/commands/open.rs | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index ccb477fd43..cd91f43aad 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -1,11 +1,15 @@ #[allow(deprecated)] -use nu_engine::{command_prelude::*, current_dir, get_eval_block}; +use nu_engine::{command_prelude::*, current_dir, eval_call}; use nu_protocol::{ ast, + debugger::{WithDebug, WithoutDebug}, shell_error::{self, io::IoError}, DataSource, NuGlob, PipelineMetadata, }; -use std::path::{Path, PathBuf}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, +}; #[cfg(feature = "sqlite")] use crate::database::SQLiteDatabase; @@ -63,7 +67,6 @@ impl Command for Open { #[allow(deprecated)] let cwd = current_dir(engine_state, stack)?; let mut paths = call.rest::>(engine_state, stack, 0)?; - let eval_block = get_eval_block(engine_state); if paths.is_empty() && !call.has_positional_args(stack, 0) { // try to use path from pipeline input if there were no positional or spread args @@ -192,13 +195,16 @@ impl Command for Open { match converter { Some((converter_id, ext)) => { - let decl = engine_state.get_decl(converter_id); - let command_output = if let Some(block_id) = decl.block_id() { - let block = engine_state.get_block(block_id); - eval_block(engine_state, stack, block, stream) + let open_call = ast::Call { + decl_id: converter_id, + head: call_span, + arguments: vec![], + parser_info: HashMap::new(), + }; + let command_output = if engine_state.is_debugging() { + eval_call::(engine_state, stack, &open_call, stream) } else { - let call = ast::Call::new(call_span); - decl.run(engine_state, stack, &(&call).into(), stream) + eval_call::(engine_state, stack, &open_call, stream) }; output.push(command_output.map_err(|inner| { ShellError::GenericError{ diff --git a/crates/nu-command/tests/commands/open.rs b/crates/nu-command/tests/commands/open.rs index 529da6c28c..04eda64c98 100644 --- a/crates/nu-command/tests/commands/open.rs +++ b/crates/nu-command/tests/commands/open.rs @@ -300,6 +300,20 @@ fn test_open_block_command() { assert_eq!(actual.out, "abcd") } +#[test] +fn test_open_with_converter_flags() { + // https://github.com/nushell/nushell/issues/13722 + let actual = nu!( + cwd: "tests/fixtures/formats", + r#" + def "from blockcommandparser" [ --flag ] { if $flag { "yes" } else { "no" } } + open sample.blockcommandparser + "# + ); + + assert_eq!(actual.out, "no") +} + #[test] fn open_ignore_ansi() { Playground::setup("open_test_ansi", |dirs, sandbox| { From 55e05be0d8c336052d552af3e82276ff3dae14ff Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 26 Mar 2025 04:28:06 +0800 Subject: [PATCH 57/59] fix(parser): comments in subexpressions of `let`/`mut` (#15375) Closes #15305 # Description Basically turns off `skip_comments` of the lex function for right hand side expressions of `let`/`mut`, just as in `parse_const`. # User-Facing Changes Should be none. # Tests + Formatting +1 # After Submitting --- crates/nu-parser/src/parse_keywords.rs | 4 +-- crates/nu-parser/src/parser.rs | 2 +- crates/nu-parser/tests/test_parser.rs | 42 ++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 31dfbb6ea3..afa875e8be 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -3331,7 +3331,7 @@ pub fn parse_let(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline spans[span.0 + 1].start, &[], &[], - true, + false, ); if let Some(parse_error) = parse_error { @@ -3613,7 +3613,7 @@ pub fn parse_mut(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline spans[span.0 + 1].start, &[], &[], - true, + false, ); if let Some(parse_error) = parse_error { diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index ef181a6a3f..ec971639c5 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -5208,7 +5208,7 @@ pub fn parse_assignment_expression( rhs_span.start, &[], &[], - true, + false, ); working_set.parse_errors.extend(rhs_error); diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index 7ae686f797..30b4c57728 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -2445,6 +2445,7 @@ mod input_types { working_set.add_decl(Box::new(Collect)); working_set.add_decl(Box::new(WithColumn)); working_set.add_decl(Box::new(IfMocked)); + working_set.add_decl(Box::new(Mut)); working_set.render() }; @@ -2573,6 +2574,44 @@ mod input_types { } } + #[test] + fn comments_within_blocks_test() { + // https://github.com/nushell/nushell/issues/15305 + let mut engine_state = EngineState::new(); + add_declarations(&mut engine_state); + + let mut working_set = StateWorkingSet::new(&engine_state); + let input = "def dummy []: int -> int { $in }"; + parse(&mut working_set, None, input.as_bytes(), true); + + for prefix in ["let ", "mut ", "mut foo = 1; $"] { + let input = format!( + r#"{}foo = 1 | + # comment + dummy"#, + prefix + ); + let block = parse(&mut working_set, None, input.as_bytes(), true); + let last_expr = &block.pipelines.last().unwrap().elements[0].expr.expr; + let block_expr = match last_expr { + Expr::Call(call) => { + assert_eq!(call.arguments.len(), 2); + call.arguments[1].expr().unwrap() + } + Expr::BinaryOp(_, _, rhs) => rhs.as_ref(), + _ => panic!("Unexpected expression: {:?}", last_expr), + }; + let block_id = match block_expr.expr { + Expr::Block(block_id) | Expr::Subexpression(block_id) => block_id, + _ => panic!("Unexpected expression: {:?}", block_expr), + }; + let rhs_expr = working_set.get_block(block_id); + assert_eq!(rhs_expr.pipelines.len(), 1); + assert_eq!(rhs_expr.pipelines[0].elements.len(), 2); + assert!(working_set.parse_errors.is_empty()); + } + } + #[test] fn operations_within_blocks_test() { let mut engine_state = EngineState::new(); @@ -2622,8 +2661,7 @@ mod input_types { .unwrap() .expr; let Expr::Call(call) = &element.expr else { - eprintln!("{:?}", element.expr); - panic!("Expected Expr::Call"); + panic!("Expected Expr::Call, but found {:?}", element.expr); }; let Expr::Keyword(else_kwd) = &call .arguments From 02fcc485fbe8947b709d91f8a27b73385311ceaa Mon Sep 17 00:00:00 2001 From: zc he Date: Wed, 26 Mar 2025 22:02:26 +0800 Subject: [PATCH 58/59] fix(parser): skip eval_const if parsing errors detected to avoid panic (#15364) Fixes #14972 #15321 #14706 # Description Early returns `NotAConstant` if parsing errors exist in the subexpression. I'm not sure when the span of a block will be None, and whether there're better ways to handle none block spans, like a more suitable ShellError type. # User-Facing Changes # Tests + Formatting +1, but possibly not the easiest way to do it. # After Submitting --- crates/nu-parser/tests/test_parser.rs | 92 ++++++++++++++++++- .../nu-protocol/src/errors/shell_error/mod.rs | 19 ++++ crates/nu-protocol/src/eval_const.rs | 8 ++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index 30b4c57728..945190014e 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -6,7 +6,7 @@ use nu_protocol::{ }; use rstest::rstest; -use mock::{Alias, AttrEcho, Def, Let, Mut, ToCustom}; +use mock::{Alias, AttrEcho, Const, Def, IfMocked, Let, Mut, ToCustom}; fn test_int( test_tag: &str, // name of sub-test @@ -784,6 +784,38 @@ pub fn parse_attributes_external_alias() { assert!(parse_error.contains("Encountered error during parse-time evaluation")); } +#[test] +pub fn parse_if_in_const_expression() { + // https://github.com/nushell/nushell/issues/15321 + let engine_state = EngineState::new(); + let mut working_set = StateWorkingSet::new(&engine_state); + + working_set.add_decl(Box::new(Const)); + working_set.add_decl(Box::new(Def)); + working_set.add_decl(Box::new(IfMocked)); + + let source = b"const foo = if t"; + let _ = parse(&mut working_set, None, source, false); + + assert!(!working_set.parse_errors.is_empty()); + let ParseError::MissingPositional(error, _, _) = &working_set.parse_errors[0] else { + panic!("Expected MissingPositional"); + }; + + assert!(error.contains("cond")); + + working_set.parse_errors = Vec::new(); + let source = b"def a [n= (if ]"; + let _ = parse(&mut working_set, None, source, false); + + assert!(!working_set.parse_errors.is_empty()); + let ParseError::UnexpectedEof(error, _) = &working_set.parse_errors[0] else { + panic!("Expected UnexpectedEof"); + }; + + assert!(error.contains(")")); +} + fn test_external_call(input: &str, tag: &str, f: impl FnOnce(&Expression, &[ExternalArgument])) { let engine_state = EngineState::new(); let mut working_set = StateWorkingSet::new(&engine_state); @@ -1969,6 +2001,51 @@ mod mock { engine::Call, Category, IntoPipelineData, PipelineData, ShellError, Type, Value, }; + #[derive(Clone)] + pub struct Const; + + impl Command for Const { + fn name(&self) -> &str { + "const" + } + + fn description(&self) -> &str { + "Create a parse-time constant." + } + + fn signature(&self) -> nu_protocol::Signature { + Signature::build("const") + .input_output_types(vec![(Type::Nothing, Type::Nothing)]) + .allow_variants_without_examples(true) + .required("const_name", SyntaxShape::VarWithOptType, "Constant name.") + .required( + "initial_value", + SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)), + "Equals sign followed by constant value.", + ) + .category(Category::Core) + } + + fn run( + &self, + _engine_state: &EngineState, + _stack: &mut Stack, + _call: &Call, + _input: PipelineData, + ) -> Result { + todo!() + } + + fn run_const( + &self, + _working_set: &StateWorkingSet, + _call: &Call, + _input: PipelineData, + ) -> Result { + Ok(PipelineData::empty()) + } + } + #[derive(Clone)] pub struct Let; @@ -2422,6 +2499,19 @@ mod mock { ) -> Result { todo!() } + + fn is_const(&self) -> bool { + true + } + + fn run_const( + &self, + _working_set: &StateWorkingSet, + _call: &Call, + _input: PipelineData, + ) -> Result { + panic!("Should not be called!") + } } } diff --git a/crates/nu-protocol/src/errors/shell_error/mod.rs b/crates/nu-protocol/src/errors/shell_error/mod.rs index 627c3679b3..84c23cd208 100644 --- a/crates/nu-protocol/src/errors/shell_error/mod.rs +++ b/crates/nu-protocol/src/errors/shell_error/mod.rs @@ -1140,6 +1140,25 @@ This is an internal Nushell error, please file an issue https://github.com/nushe span: Span, }, + /// TODO: Get rid of this error by moving the check before evaluation + /// + /// Tried evaluating of a subexpression with parsing error + /// + /// ## Resolution + /// + /// Fix the parsing error first. + #[error("Found parsing error in expression.")] + #[diagnostic( + code(nu::shell::parse_error_in_constant), + help( + "This expression is supposed to be evaluated into a constant, which means error-free." + ) + )] + ParseErrorInConstant { + #[label("Parsing error detected in expression")] + span: Span, + }, + /// Tried assigning non-constant value to a constant /// /// ## Resolution diff --git a/crates/nu-protocol/src/eval_const.rs b/crates/nu-protocol/src/eval_const.rs index 86ce4d7385..15ad479e19 100644 --- a/crates/nu-protocol/src/eval_const.rs +++ b/crates/nu-protocol/src/eval_const.rs @@ -508,6 +508,14 @@ impl Eval for EvalConst { block_id: BlockId, span: Span, ) -> Result { + // If parsing errors exist in the subexpression, don't bother to evaluate it. + if working_set + .parse_errors + .iter() + .any(|error| span.contains_span(error.span())) + { + return Err(ShellError::ParseErrorInConstant { span }); + } // TODO: Allow debugging const eval let block = working_set.get_block(block_id); eval_const_subexpression(working_set, block, PipelineData::empty(), span)?.into_value(span) From 1979b61a92d4128f33dbffdf09fa1dc1e946ee07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:12:42 +0000 Subject: [PATCH 59/59] build(deps): bump tokio from 1.43.0 to 1.44.1 (#15419) --- Cargo.lock | 4 ++-- crates/nu_plugin_polars/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28017902c5..b5ac70089f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7221,9 +7221,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" dependencies = [ "backtrace", "bytes", diff --git a/crates/nu_plugin_polars/Cargo.toml b/crates/nu_plugin_polars/Cargo.toml index ce91ab3d2f..033eb533ee 100644 --- a/crates/nu_plugin_polars/Cargo.toml +++ b/crates/nu_plugin_polars/Cargo.toml @@ -46,7 +46,7 @@ hashbrown = { version = "0.15", features = ["rayon", "serde"] } # Cloud support aws-config = { version = "1.5", features = ["sso"] } aws-credential-types = "1.2" -tokio = { version = "1.43", features = ["full"] } +tokio = { version = "1.44", features = ["full"] } object_store = { version = "0.11", default-features = false } url.workspace = true