Skip to content

Commit

Permalink
bump Nushell and the plugin (#37)
Browse files Browse the repository at this point in the history
as per title
  • Loading branch information
amtoine authored Mar 6, 2024
1 parent cbbb1e1 commit 942bb80
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
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.90.1"
nu-protocol = { version = "0.90.1", features = ["plugin"] }
nu-plugin = "0.91.0"
nu-protocol = { version = "0.91.0", features = ["plugin"] }
ratatui = "0.26.1"
url = "2.4.0"

Expand All @@ -17,4 +17,4 @@ bench = false
[package]
edition = "2021"
name = "nu_plugin_explore"
version = "0.1.2"
version = "0.2.0"
6 changes: 4 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,10 @@ mod tests {
let value = Value::test_record(record! {
"show_cell_path" => Value::test_bool(false)
});
let mut expected = Config::default();
expected.show_cell_path = false;
let expected = Config {
show_cell_path: false,
..Default::default()
};
assert_eq!(Config::from_value(value), Ok(expected));

let value = Value::test_record(record! {
Expand Down
2 changes: 1 addition & 1 deletion src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Editor {

pub(super) fn from_value(value: &Value) -> Self {
Self {
buffer: value.into_string(" ", &nu_protocol::Config::default()),
buffer: value.to_expanded_string(" ", &nu_protocol::Config::default()),
cursor_position: (0, 0),
width: 0,
}
Expand Down
29 changes: 14 additions & 15 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ mod tests {
let mode = app.mode.clone();

let result =
handle_key_events(KeyEvent::new(key, KeyModifiers::empty()), &mut app, &config)
handle_key_events(KeyEvent::new(key, KeyModifiers::empty()), &mut app, config)
.unwrap();

if exit {
Expand Down Expand Up @@ -438,14 +438,15 @@ mod tests {
mode
),
},
None => match result {
TransitionResult::Return(_) => panic!(
"did NOT expect output data after pressing {} in {} mode",
repr_keycode(&key),
mode
),
_ => {}
},
None => {
if let TransitionResult::Return(_) = result {
panic!(
"did NOT expect output data after pressing {} in {} mode",
repr_keycode(&key),
mode
)
}
}
}
}
}
Expand Down Expand Up @@ -555,13 +556,11 @@ mod tests {

for (key, cell_path) in transitions {
let expected = to_path_member_vec(&cell_path);
match handle_key_events(KeyEvent::new(key, KeyModifiers::empty()), &mut app, &config)
.unwrap()
if let TransitionResult::Mutate(cell, path) =
handle_key_events(KeyEvent::new(key, KeyModifiers::empty()), &mut app, &config)
.unwrap()
{
TransitionResult::Mutate(cell, path) => {
app.value = crate::nu::value::mutate_value_cell(&app.value, &path, &cell)
}
_ => {}
app.value = crate::nu::value::mutate_value_cell(&app.value, &path, &cell)
}

assert!(
Expand Down
6 changes: 4 additions & 2 deletions src/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ pub(super) fn go_up_or_down_in_data(app: &mut App, direction: Direction) {
panic!(
"unexpected error when following {:?} in {}",
app.position.members,
app.value.into_string(" ", &nu_protocol::Config::default())
app.value
.to_expanded_string(" ", &nu_protocol::Config::default())
)
});

Expand Down Expand Up @@ -116,7 +117,8 @@ pub(super) fn go_deeper_in_data(app: &mut App) {
panic!(
"unexpected error when following {:?} in {}",
app.position.members,
app.value.into_string(" ", &nu_protocol::Config::default())
app.value
.to_expanded_string(" ", &nu_protocol::Config::default())
)
});

Expand Down
30 changes: 12 additions & 18 deletions src/nu/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub(crate) fn transpose(value: &Value) -> Value {
if first_row.len() == 2 {
let cols: Vec<String> = value_rows
.iter()
.map(|row| row.get_data_by_key("1").unwrap().as_string().unwrap())
.map(|row| row.get_data_by_key("1").unwrap().as_str().unwrap().into())
.collect();

let vals: Vec<Value> = value_rows
Expand All @@ -191,7 +191,7 @@ pub(crate) fn transpose(value: &Value) -> Value {
let mut rows = vec![];
let cols: Vec<String> = value_rows
.iter()
.map(|v| v.get_data_by_key("1").unwrap().as_string().unwrap())
.map(|v| v.get_data_by_key("1").unwrap().as_str().unwrap().into())
.collect();

for i in 0..(first_row.len() - 1) {
Expand Down Expand Up @@ -262,7 +262,7 @@ mod tests {
use nu_protocol::{ast::CellPath, record, Config, Value};

fn default_value_repr(value: &Value) -> String {
value.into_string(" ", &Config::default())
value.to_expanded_string(" ", &Config::default())
}

#[test]
Expand Down Expand Up @@ -410,9 +410,8 @@ mod tests {
"b" => Value::test_int(2),
}),
]);
assert_eq!(
assert!(
is_table(&table),
true,
"{} should be a table",
default_value_repr(&table)
);
Expand All @@ -427,9 +426,8 @@ mod tests {
"b" => Value::test_int(2),
}),
]);
assert_eq!(
assert!(
is_table(&table_with_out_of_order_columns),
true,
"{} should be a table",
default_value_repr(&table_with_out_of_order_columns)
);
Expand All @@ -444,9 +442,8 @@ mod tests {
"b" => Value::test_int(2),
}),
]);
assert_eq!(
assert!(
is_table(&table_with_nulls),
true,
"{} should be a table",
default_value_repr(&table_with_nulls)
);
Expand All @@ -461,9 +458,8 @@ mod tests {
"b" => Value::test_float(2.34),
}),
]);
assert_eq!(
assert!(
is_table(&table_with_number_colum),
true,
"{} should be a table",
default_value_repr(&table_with_number_colum)
);
Expand All @@ -477,9 +473,8 @@ mod tests {
"b" => Value::test_int(1),
}),
]);
assert_eq!(
is_table(&not_a_table_missing_field),
false,
assert!(
!is_table(&not_a_table_missing_field),
"{} should not be a table",
default_value_repr(&not_a_table_missing_field)
);
Expand All @@ -494,14 +489,13 @@ mod tests {
"b" => Value::test_list(vec![Value::test_int(1)]),
}),
]);
assert_eq!(
is_table(&not_a_table_incompatible_types),
false,
assert!(
!is_table(&not_a_table_incompatible_types),
"{} should not be a table",
default_value_repr(&not_a_table_incompatible_types)
);

assert_eq!(is_table(&Value::test_int(0)), false);
assert!(!is_table(&Value::test_int(0)));
}

#[test]
Expand Down
5 changes: 3 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn repr_simple_value(value: &Value) -> DataRowRepr {
name: None,
shape,
// FIXME: use a real config
data: value.into_string(" ", &nu_protocol::Config::default()),
data: value.to_expanded_string(" ", &nu_protocol::Config::default()),
}
}

Expand Down Expand Up @@ -246,7 +246,8 @@ fn render_data(frame: &mut Frame, app: &App, config: &Config) {
panic!(
"unexpected error when following {:?} in {}",
app.position.members,
app.value.into_string(" ", &nu_protocol::Config::default())
app.value
.to_expanded_string(" ", &nu_protocol::Config::default())
)
});

Expand Down

0 comments on commit 942bb80

Please sign in to comment.