From d091c3799dac41fc81daab4058f2e05115751b04 Mon Sep 17 00:00:00 2001 From: amtoine Date: Tue, 16 Jan 2024 18:00:08 +0100 Subject: [PATCH 1/5] bump Nushell to 0.89.0 --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e14e7ba..4374a5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,8 @@ name = "nu_plugin_explore" anyhow = "1.0.73" console = "0.15.7" crossterm = "0.27.0" -nu-plugin = "0.87.0" -nu-protocol = { version = "0.87.0", features = ["plugin"] } +nu-plugin = "0.89.0" +nu-protocol = { version = "0.89.0", features = ["plugin"] } ratatui = "0.22.0" url = "2.4.0" From a09fc7bade66baabc3219698330f42e30186bda2 Mon Sep 17 00:00:00 2001 From: amtoine Date: Tue, 16 Jan 2024 18:00:30 +0100 Subject: [PATCH 2/5] fix "private vals" with `Record::from_raw_cols_vals` --- src/nu/value.rs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/nu/value.rs b/src/nu/value.rs index ac766b0..4629839 100644 --- a/src/nu/value.rs +++ b/src/nu/value.rs @@ -45,15 +45,21 @@ pub(crate) fn mutate_value_cell(value: &Value, cell_path: &CellPath, cell: &Valu let id = rec.cols.iter().position(|x| *x == col).unwrap_or(0); - let mut vals = rec.vals.clone(); - vals[id] = mutate_value_cell(&vals[id], &cell_path, cell); - - let mut record = Record::new(); - rec.cols.iter().zip(vals).for_each(|(col, val)| { - record.push(col, val); - }); + let cols = rec.columns().cloned().collect(); + let vals = rec + .values() + .cloned() + .enumerate() + .map(|(i, v)| { + if i == id { + mutate_value_cell(&v, &cell_path, cell) + } else { + v + } + }) + .collect(); - Value::record(record, Span::unknown()) + Value::record(Record::from_raw_cols_vals(cols, vals), Span::unknown()) } _ => cell.clone(), } @@ -173,7 +179,7 @@ pub(crate) fn transpose(value: &Value) -> Value { .map(|row| row.get_data_by_key("2").unwrap()) .collect(); - return Value::record(Record { cols, vals }, Span::unknown()); + return Value::record(Record::from_raw_cols_vals(cols, vals), Span::unknown()); } else { let mut rows = vec![]; let cols: Vec = value_rows @@ -183,13 +189,13 @@ pub(crate) fn transpose(value: &Value) -> Value { for i in 0..(first_row.len() - 1) { rows.push(Value::record( - Record { - cols: cols.clone(), - vals: value_rows + Record::from_raw_cols_vals( + cols.clone(), + value_rows .iter() .map(|v| v.get_data_by_key(&format!("{}", i + 2)).unwrap()) .collect(), - }, + ), Span::unknown(), )); } @@ -208,7 +214,10 @@ pub(crate) fn transpose(value: &Value) -> Value { vs.push(v.get_data_by_key(col).unwrap()); } - rows.push(Value::record(Record { cols, vals: vs }, Span::unknown())); + rows.push(Value::record( + Record::from_raw_cols_vals(cols, vs), + Span::unknown(), + )); } return Value::list(rows, Span::unknown()); From 623096ccd143c49e45d96111637dc2dce73a5e94 Mon Sep 17 00:00:00 2001 From: amtoine Date: Tue, 16 Jan 2024 18:01:55 +0100 Subject: [PATCH 3/5] bump the package to 0.1.2 --- Cargo.toml | 2 +- nupm.nuon | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4374a5a..a155297 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,4 @@ bench = false [package] edition = "2021" name = "nu_plugin_explore" -version = "0.1.1" +version = "0.1.2" diff --git a/nupm.nuon b/nupm.nuon index 2075973..f4dd4f2 100644 --- a/nupm.nuon +++ b/nupm.nuon @@ -1,7 +1,7 @@ { name: nu_plugin_explore, - version: "0.1.1", + version: "0.1.2", description: "A fast structured data explorer for Nushell.", license: LICENSE, type: custom -} \ No newline at end of file +} From c97db95d4b1eca44fc15a031adc69b0a25d936a7 Mon Sep 17 00:00:00 2001 From: amtoine Date: Tue, 16 Jan 2024 18:09:38 +0100 Subject: [PATCH 4/5] remove the dev-deps script and use `Cargo.toml` --- .github/workflows/main.yml | 12 ------------ scripts/setup-dev-deps | 15 --------------- 2 files changed, 27 deletions(-) delete mode 100755 scripts/setup-dev-deps diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53ffb66..e402d02 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,12 +24,6 @@ jobs: - name: Format run: cargo fmt --all -- --check - - name: Setup dependencies - run: | - git clone https://github.com/nushell/nushell - make NUSHELL_PATH=nushell dev-deps - shell: bash - - name: Check the library run: cargo check --workspace --lib @@ -55,11 +49,5 @@ jobs: with: rustflags: "" - - name: Setup dependencies - run: | - git clone https://github.com/nushell/nushell - make NUSHELL_PATH=nushell dev-deps - shell: bash - - name: Tests run: cargo test --workspace diff --git a/scripts/setup-dev-deps b/scripts/setup-dev-deps deleted file mode 100755 index 0c8c6e5..0000000 --- a/scripts/setup-dev-deps +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z "$NUSHELL_PATH" ]]; then - path=$(cargo install --list | grep '^nu v' | sed 's/^.*(//; s/):$//') - - [[ -z "$path" ]] && { - echo "couldn't find path to nushell source, please set \`NUSHELL_PATH\` manually" - exit 0 - } -else - path="$NUSHELL_PATH" -fi - -cargo add nu-plugin --path "$path/crates/nu-plugin/" -cargo add nu-protocol --path "$path/crates/nu-protocol/" --features plugin From 74175d5b0081f2bb02a7ca44ac62aa40e76845a4 Mon Sep 17 00:00:00 2001 From: amtoine Date: Tue, 16 Jan 2024 18:12:32 +0100 Subject: [PATCH 5/5] make Clippy happy --- src/app.rs | 2 +- src/handler.rs | 2 +- src/navigation.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index d4bce1b..06f1c89 100755 --- a/src/app.rs +++ b/src/app.rs @@ -73,7 +73,7 @@ impl App { optional: vals.is_empty(), }), Value::Record { val: rec, .. } => app.position.members.push(PathMember::String { - val: rec.cols.get(0).unwrap_or(&"".to_string()).into(), + val: rec.cols.first().unwrap_or(&"".to_string()).into(), span: Span::unknown(), optional: rec.cols.is_empty(), }), diff --git a/src/handler.rs b/src/handler.rs index 6fac297..a5664d5 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -72,7 +72,7 @@ pub fn handle_key_events( Value::Record { val: rec, .. } => { // NOTE: app.position.members should never be empty by construction *app.position.members.last_mut().unwrap() = PathMember::String { - val: rec.cols.get(0).unwrap_or(&"".to_string()).to_string(), + val: rec.cols.first().unwrap_or(&"".to_string()).to_string(), span: Span::unknown(), optional: rec.cols.is_empty(), }; diff --git a/src/navigation.rs b/src/navigation.rs index eb70444..c4dc5e0 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -127,7 +127,7 @@ pub(super) fn go_deeper_in_data(app: &mut App) { optional: vals.is_empty(), }), Value::Record { val: rec, .. } => app.position.members.push(PathMember::String { - val: rec.cols.get(0).unwrap_or(&"".to_string()).into(), + val: rec.cols.first().unwrap_or(&"".to_string()).into(), span: Span::unknown(), optional: rec.cols.is_empty(), }),