From 5656207624b9040acf034a0eacac56585f49b9b9 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 1 Mar 2024 21:34:06 +0100 Subject: [PATCH] Update to latest nu version --- Cargo.toml | 18 +++++------ src/context/bindings.rs | 66 ++--------------------------------------- src/context/builder.rs | 1 - src/error.rs | 2 +- src/into_expression.rs | 21 ++++++------- src/into_value.rs | 36 +++++++++++----------- tests/test_eval.rs | 2 +- 7 files changed, 39 insertions(+), 107 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a9c633..ddaf1c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "embed-nu" -version = "0.8.0" +version = "0.9.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/Trivernis/embed-nu" @@ -10,12 +10,12 @@ authors = ["trivernis "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -miette = "5.9.0" -nu-cmd-lang = "0.80.0" -nu-command = "0.80.0" -nu-engine = "0.80.0" -nu-parser = "0.80.0" -nu-protocol = "0.80.0" -paste = "1.0.12" +miette = "7.1.0" +nu-cmd-lang = "0.90.1" +nu-command = "0.90.1" +nu-engine = "0.90.1" +nu-parser = "0.90.1" +nu-protocol = "0.90.1" +paste = "1.0.14" rusty-value = { version = "0.6.0", features = ["derive"] } -thiserror = "1.0.40" +thiserror = "1.0.57" diff --git a/src/context/bindings.rs b/src/context/bindings.rs index 9edb398..fbd6112 100644 --- a/src/context/bindings.rs +++ b/src/context/bindings.rs @@ -22,7 +22,6 @@ pub fn bind_core_commands(engine_state: &mut EngineState) -> CrateResult<()> { Const, Continue, Def, - DefEnv, Describe, Do, Echo, @@ -30,7 +29,6 @@ pub fn bind_core_commands(engine_state: &mut EngineState) -> CrateResult<()> { ExportAlias, ExportCommand, ExportDef, - ExportDefEnv, ExportExtern, ExportUse, Extern, @@ -71,7 +69,6 @@ pub fn bind_debug_commands(engine_state: &mut EngineState) -> CrateResult<()> { Explain, Inspect, Metadata, - Profile, TimeIt, View, ViewFiles, @@ -97,7 +94,6 @@ pub fn bind_filter_commands(engine_state: &mut EngineState) -> CrateResult<()> { DropColumn, DropNth, Each, - EachWhile, Empty, Enumerate, Every, @@ -127,12 +123,6 @@ pub fn bind_filter_commands(engine_state: &mut EngineState) -> CrateResult<()> { Reject, Rename, Reverse, - Roll, - RollDown, - RollUp, - RollLeft, - RollRight, - Rotate, Select, Shuffle, Skip, @@ -146,7 +136,6 @@ pub fn bind_filter_commands(engine_state: &mut EngineState) -> CrateResult<()> { UniqBy, Upsert, Update, - UpdateCells, Values, Where, Window, @@ -224,20 +213,15 @@ pub fn bind_string_commands(engine_state: &mut EngineState) -> CrateResult<()> { Encode, DecodeBase64, EncodeBase64, - DecodeHex, - EncodeHex, DetectColumns, Format, - FileSize, Parse, - Size, Split, SplitChars, SplitColumn, SplitRow, SplitWords, Str, - StrCamelCase, StrCapitalize, StrContains, StrDistance, @@ -246,35 +230,15 @@ pub fn bind_string_commands(engine_state: &mut EngineState) -> CrateResult<()> { StrJoin, StrReplace, StrIndexOf, - StrKebabCase, StrLength, - StrPascalCase, StrReverse, - StrScreamingSnakeCase, - StrSnakeCase, StrStartsWith, StrSubstring, StrTrim, - StrTitleCase, StrUpcase } } -pub fn bind_bit_commands(engine_state: &mut EngineState) -> CrateResult<()> { - bind_commands! { - engine_state, - Bits, - BitsAnd, - BitsNot, - BitsOr, - BitsXor, - BitsRotateLeft, - BitsRotateRight, - BitsShiftLeft, - BitsShiftRight, - } -} - pub fn bind_byte_commands(engine_state: &mut EngineState) -> CrateResult<()> { bind_commands! { engine_state, @@ -297,10 +261,10 @@ pub fn bind_file_system_commands(engine_state: &mut EngineState) -> CrateResult< bind_commands! { engine_state, Cd, - Cp, + UCp, Ls, Mkdir, - Mv, + UMv, Open, Rm, Save, @@ -314,8 +278,6 @@ pub fn bind_platform_commands(engine_state: &mut EngineState) -> CrateResult<()> bind_commands! { engine_state, Ansi, - AnsiGradient, - AnsiStrip, Clear, Du, Input, @@ -357,14 +319,12 @@ pub fn bind_format_commands(engine_state: &mut EngineState) -> CrateResult<()> { FromSsv, FromToml, FromTsv, - FromUrl, FromXlsx, FromXml, FromYaml, FromYml, To, ToCsv, - ToHtml, ToJson, ToMd, ToNuon, @@ -384,7 +344,6 @@ pub fn bind_viewer_commands(engine_state: &mut EngineState) -> CrateResult<()> { engine_state, Griddle, Table, - Explore, } } @@ -392,12 +351,10 @@ pub fn bind_conversion_commands(engine_state: &mut EngineState) -> CrateResult<( bind_commands! { engine_state, Fill, - Fmt, Into, IntoBool, IntoBinary, IntoDatetime, - IntoDecimal, IntoDuration, IntoFilesize, IntoInt, @@ -437,23 +394,6 @@ pub fn bind_math_commands(engine_state: &mut EngineState) -> CrateResult<()> { MathStddev, MathSum, MathVariance, - MathSin, - MathCos, - MathTan, - MathSinH, - MathCosH, - MathTanH, - MathArcSin, - MathArcCos, - MathArcTan, - MathArcSinH, - MathArcCosH, - MathArcTanH, - MathPi, - MathTau, - MathEuler, - MathExp, - MathLn, MathLog, } } @@ -483,9 +423,7 @@ pub fn bind_random_commands(engine_state: &mut EngineState) -> CrateResult<()> { Random, RandomBool, RandomChars, - RandomDecimal, RandomDice, - RandomInteger, RandomUuid, } } diff --git a/src/context/builder.rs b/src/context/builder.rs index 8ad6993..7a58406 100644 --- a/src/context/builder.rs +++ b/src/context/builder.rs @@ -54,7 +54,6 @@ impl ContextBuilder { path, system, string, - bit, byte, file_system, platform, diff --git a/src/error.rs b/src/error.rs index d6fac19..eec9b49 100644 --- a/src/error.rs +++ b/src/error.rs @@ -12,7 +12,7 @@ pub enum CrateError { #[error("Parse Error {0:?}")] #[diagnostic()] - NuParseErrors(#[related] Vec), + NuParseErrors(Vec), #[error("Could not find the function {0}")] #[diagnostic()] diff --git a/src/into_expression.rs b/src/into_expression.rs index b060af2..b39c6d1 100644 --- a/src/into_expression.rs +++ b/src/into_expression.rs @@ -1,5 +1,5 @@ use nu_protocol::{ - ast::{Expr, Expression}, + ast::{Expr, Expression, RecordItem}, Span, Value, }; @@ -42,16 +42,13 @@ impl ValueIntoExpression for Value { Value::Duration { val, .. } => Expr::Int(val), Value::Date { val, .. } => Expr::DateTime(val), Value::String { val, .. } => Expr::String(val), - Value::Record { - mut cols, mut vals, .. - } => { - let mut entries = Vec::new(); - - for _ in 0..cols.len() { - let col = cols.remove(0).into_expression(); - let val = vals.remove(0).into_expression(); - entries.push((col, val)); - } + Value::Record { val, .. } => { + let entries = val + .into_iter() + .map(|(col, val)| { + RecordItem::Pair(col.into_expression(), val.into_expression()) + }) + .collect(); Expr::Record(entries) } @@ -61,7 +58,7 @@ impl ValueIntoExpression for Value { } Value::Block { val, .. } => Expr::Block(val), Value::Nothing { .. } => Expr::Nothing, - Value::Error { error } => Expr::String(error.to_string()), + Value::Error { error, .. } => Expr::String(error.to_string()), Value::Binary { val, .. } => Expr::Binary(val), Value::CellPath { val, .. } => Expr::CellPath(val), _ => Expr::Nothing, diff --git a/src/into_value.rs b/src/into_value.rs index 2345e5c..053dfa8 100644 --- a/src/into_value.rs +++ b/src/into_value.rs @@ -1,4 +1,4 @@ -use nu_protocol::{Span, Value}; +use nu_protocol::{Record, Span, Value}; use rusty_value::{Fields, HashableValue, RustyValue}; use crate::utils::NewEmpty; @@ -48,7 +48,7 @@ impl RustyIntoValue for Vec { fn into_value(self) -> Value { Value::List { vals: self, - span: Span::empty(), + internal_span: Span::empty(), } } } @@ -61,7 +61,7 @@ impl RustyIntoValue for rusty_value::Value { if let Fields::Unit = &s.fields { Value::String { val: s.name, - span: Span::empty(), + internal_span: Span::empty(), } } else { s.fields.into_value() @@ -71,7 +71,7 @@ impl RustyIntoValue for rusty_value::Value { if let Fields::Unit = &e.fields { Value::String { val: e.variant, - span: Span::empty(), + internal_span: Span::empty(), } } else { e.fields.into_value() @@ -86,9 +86,8 @@ impl RustyIntoValue for rusty_value::Value { vals.push(val.into_value()); } Value::Record { - cols, - vals, - span: Span::empty(), + val: Record::from_raw_cols_vals_unchecked(cols, vals), + internal_span: Span::empty(), } } rusty_value::Value::List(l) => { @@ -96,11 +95,11 @@ impl RustyIntoValue for rusty_value::Value { Value::List { vals, - span: Span::empty(), + internal_span: Span::empty(), } } rusty_value::Value::None => Value::Nothing { - span: Span::empty(), + internal_span: Span::empty(), }, } } @@ -113,15 +112,15 @@ impl RustyIntoValue for rusty_value::Primitive { rusty_value::Primitive::Float(f) => f.into_value(), rusty_value::Primitive::String(val) => Value::String { val, - span: Span::empty(), + internal_span: Span::empty(), }, rusty_value::Primitive::Char(val) => Value::String { val: val.to_string(), - span: Span::empty(), + internal_span: Span::empty(), }, rusty_value::Primitive::Bool(val) => Value::Bool { val, - span: Span::empty(), + internal_span: Span::empty(), }, rusty_value::Primitive::OsString(osstr) => osstr.to_string_lossy().into_value(), } @@ -140,9 +139,8 @@ impl RustyIntoValue for rusty_value::Fields { vals.push(v.into_value()); } Value::Record { - cols, - vals, - span: Span::empty(), + val: Record::from_raw_cols_vals_unchecked(cols, vals), + internal_span: Span::empty(), } } rusty_value::Fields::Unnamed(unnamed) => { @@ -158,12 +156,12 @@ impl RustyIntoValue for rusty_value::Fields { } else { Value::List { vals, - span: Span::empty(), + internal_span: Span::empty(), } } } rusty_value::Fields::Unit => Value::Nothing { - span: Span::empty(), + internal_span: Span::empty(), }, } } @@ -187,7 +185,7 @@ impl RustyIntoValue for rusty_value::Integer { }; Value::Int { val, - span: Span::empty(), + internal_span: Span::empty(), } } } @@ -201,7 +199,7 @@ impl RustyIntoValue for rusty_value::Float { }; Value::Float { val, - span: Span::empty(), + internal_span: Span::empty(), } } } diff --git a/tests/test_eval.rs b/tests/test_eval.rs index fda9c56..1fcd36d 100644 --- a/tests/test_eval.rs +++ b/tests/test_eval.rs @@ -18,7 +18,7 @@ fn it_evals_strings() { #[test] fn it_reports_parse_errors() { let mut ctx = get_context(); - let eval_result = ctx.eval_raw(r#"let a = 1 | 2 | 3"#, PipelineData::empty()); + let eval_result = ctx.eval_raw(r#"let a = 1 || 2"#, PipelineData::empty()); assert!(eval_result.is_err()); }