Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump Nushell to 0.89.0 and the plugin to 0.1.2 #29

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -17,4 +17,4 @@ bench = false
[package]
edition = "2021"
name = "nu_plugin_explore"
version = "0.1.1"
version = "0.1.2"
4 changes: 2 additions & 2 deletions nupm.nuon
Original file line number Diff line number Diff line change
@@ -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
}
}
15 changes: 0 additions & 15 deletions scripts/setup-dev-deps

This file was deleted.

2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
Expand Down
2 changes: 1 addition & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
Expand Down
37 changes: 23 additions & 14 deletions src/nu/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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<String> = value_rows
Expand All @@ -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(),
));
}
Expand All @@ -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());
Expand Down