Compare commits

..

No commits in common. '9c525c6c28274ff20557fde91d4e6e7e05b505dd' and '691f91efdf9b2fc0e58738b16be9a8cae11917e4' have entirely different histories.

@ -1,6 +1,6 @@
[package]
name = "embed-nu"
version = "0.5.1"
version = "0.3.5"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/Trivernis/embed-nu"
@ -10,11 +10,10 @@ authors = ["trivernis <trivernis@proton.me>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
miette = "5.5.0"
nu-command = "0.75.0"
nu-engine = "0.75.0"
nu-parser = "0.75.0"
nu-protocol = "0.75.0"
paste = "1.0.11"
nu-command = "0.71.0"
nu-engine = "0.71.0"
nu-parser = "0.71.0"
nu-protocol = "0.71.0"
paste = "1.0.9"
rusty-value = { version = "0.6.0", features = ["derive"] }
thiserror = "1.0.38"
thiserror = "1.0.37"

@ -16,9 +16,7 @@ pub fn bind_core_commands(engine_state: &mut EngineState) -> CrateResult<()> {
engine_state,
Alias,
Ast,
Break,
Commandline,
Continue,
Debug,
Def,
DefEnv,
@ -35,7 +33,6 @@ pub fn bind_core_commands(engine_state: &mut EngineState) -> CrateResult<()> {
Extern,
For,
Help,
HelpOperators,
Hide,
HideEnv,
If,
@ -48,12 +45,8 @@ pub fn bind_core_commands(engine_state: &mut EngineState) -> CrateResult<()> {
Let,
Metadata,
Module,
Mut,
Return,
Try,
Use,
Version,
While,
)
}
@ -63,68 +56,69 @@ pub fn bind_chart_commands(engine_state: &mut EngineState) -> CrateResult<()> {
pub fn bind_filter_commands(engine_state: &mut EngineState) -> CrateResult<()> {
bind_commands! {
engine_state,
All,
Any,
Append,
Collect,
Columns,
Compact,
Default,
Drop,
DropColumn,
DropNth,
Each,
EachWhile,
Empty,
Every,
Find,
First,
Flatten,
Get,
Group,
GroupBy,
Headers,
Insert,
SplitBy,
Take,
Merge,
Move,
TakeWhile,
TakeUntil,
Last,
Length,
Lines,
ParEach,
Prepend,
Range,
Reduce,
Reject,
Rename,
Reverse,
Roll,
RollDown,
RollUp,
RollLeft,
RollRight,
Rotate,
Select,
Shuffle,
Skip,
SkipUntil,
SkipWhile,
Sort,
SortBy,
SplitList,
Transpose,
Uniq,
Upsert,
Update,
UpdateCells,
Where,
Window,
Wrap,
Zip, }
engine_state,
All,
Any,
Append,
Collect,
Columns,
Compact,
Default,
Drop,
DropColumn,
DropNth,
Each,
EachWhile,
Empty,
Every,
Find,
First,
Flatten,
Get,
Group,
GroupBy,
Headers,
Insert,
SplitBy,
Take,
Merge,
Move,
TakeWhile,
TakeUntil,
Last,
Length,
Lines,
ParEach,
Prepend,
Range,
Reduce,
Reject,
Rename,
Reverse,
Roll,
RollDown,
RollUp,
RollLeft,
RollRight,
Rotate,
Select,
Shuffle,
Skip,
SkipUntil,
SkipWhile,
Sort,
SortBy,
SplitList,
Transpose,
Uniq,
Upsert,
Update,
UpdateCells,
Where,
Window,
Wrap,
Zip,
}
}
pub fn bind_misc_commands(engine_state: &mut EngineState) -> CrateResult<()> {
@ -157,13 +151,13 @@ pub fn bind_system_commands(engine_state: &mut EngineState) -> CrateResult<()> {
NuCheck,
Sys,
Ps,
Which,
}
}
pub fn bind_string_commands(engine_state: &mut EngineState) -> CrateResult<()> {
bind_commands! {
engine_state,
BuildString,
Char,
Decode,
Encode,
@ -202,7 +196,7 @@ pub fn bind_string_commands(engine_state: &mut EngineState) -> CrateResult<()> {
StrSubstring,
StrTrim,
StrTitleCase,
StrUpcase,
StrUpcase
}
}
@ -330,10 +324,12 @@ pub fn bind_format_commands(engine_state: &mut EngineState) -> CrateResult<()> {
ToText,
ToToml,
ToTsv,
ToCsv,
Touch,
Use,
Upsert,
Where,
ToUrl,
ToXml,
ToYaml,
}
@ -359,7 +355,6 @@ pub fn bind_conversion_commands(engine_state: &mut EngineState) -> CrateResult<(
IntoDuration,
IntoFilesize,
IntoInt,
IntoRecord,
IntoString,
}
}
@ -385,6 +380,7 @@ pub fn bind_math_commands(engine_state: &mut EngineState) -> CrateResult<()> {
MathAbs,
MathAvg,
MathCeil,
MathEval,
MathFloor,
MathMax,
MathMedian,
@ -402,8 +398,13 @@ pub fn bind_math_commands(engine_state: &mut EngineState) -> CrateResult<()> {
pub fn bind_network_commands(engine_state: &mut EngineState) -> CrateResult<()> {
bind_commands! {
engine_state,
Fetch,
Post,
Url,
UrlParse,
UrlHost,
UrlPath,
UrlQuery,
UrlScheme,
Port,
}
}

@ -93,7 +93,6 @@ impl ContextBuilder {
name.to_string().into_bytes(),
Span::empty(),
nu_protocol::Type::Any,
false,
);
self.stack.add_var(var_id, value.into_value());
let delta = working_set.render();

@ -99,7 +99,6 @@ impl Context {
arguments: args,
redirect_stdout: true,
redirect_stderr: true,
parser_info: Vec::new(),
};
let data = nu_engine::eval_call(

@ -1,4 +1,3 @@
use miette::Diagnostic;
use nu_parser::ParseError;
use nu_protocol::ShellError;
use thiserror::Error;
@ -16,71 +15,3 @@ pub enum CrateError {
#[error("Could not find the function {0}")]
FunctionNotFound(String),
}
impl Diagnostic for CrateError {
fn code<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
match self {
CrateError::NuShellError(n) => n.code(),
CrateError::NuParseError(n) => n.code(),
Self::FunctionNotFound(_) => Some(Box::new("embed_nu::fn_not_found")),
}
}
fn severity(&self) -> Option<miette::Severity> {
match self {
CrateError::NuShellError(n) => n.severity(),
CrateError::NuParseError(n) => n.severity(),
_ => None,
}
}
fn help<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
match self {
CrateError::NuShellError(n) => n.help(),
CrateError::NuParseError(n) => n.help(),
CrateError::FunctionNotFound(_) => Some(Box::new(
"Make sure the function you want to execute is defined at this point.",
)),
}
}
fn url<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
match self {
CrateError::NuShellError(n) => n.url(),
CrateError::NuParseError(n) => n.url(),
_ => None,
}
}
fn source_code(&self) -> Option<&dyn miette::SourceCode> {
match self {
CrateError::NuShellError(n) => n.source_code(),
CrateError::NuParseError(n) => n.source_code(),
_ => None,
}
}
fn labels(&self) -> Option<Box<dyn Iterator<Item = miette::LabeledSpan> + '_>> {
match self {
CrateError::NuShellError(n) => n.labels(),
CrateError::NuParseError(n) => n.labels(),
_ => None,
}
}
fn related<'a>(&'a self) -> Option<Box<dyn Iterator<Item = &'a dyn Diagnostic> + 'a>> {
match self {
CrateError::NuShellError(n) => n.related(),
CrateError::NuParseError(n) => n.related(),
_ => None,
}
}
fn diagnostic_source(&self) -> Option<&dyn Diagnostic> {
match self {
CrateError::NuShellError(n) => n.diagnostic_source(),
CrateError::NuParseError(n) => n.diagnostic_source(),
_ => None,
}
}
}

@ -1,7 +1,7 @@
use nu_protocol::{
ast::Block,
engine::{EngineState, StateWorkingSet},
Span,
PipelineData, Span,
};
use crate::error::{CrateError, CrateResult};
@ -17,6 +17,13 @@ impl NewEmpty for Span {
}
}
impl NewEmpty for PipelineData {
#[inline]
fn empty() -> Self {
Self::new(Span::empty())
}
}
pub fn parse_nu_script(engine_state: &mut EngineState, contents: String) -> CrateResult<Block> {
let mut working_set = StateWorkingSet::new(&engine_state);
let (block, err) = nu_parser::parse(&mut working_set, None, &contents.into_bytes(), false, &[]);

@ -1,5 +1,5 @@
use embed_nu::{rusty_value::*, IntoValue};
use embed_nu::{CommandGroupConfig, Context, PipelineData};
use embed_nu::{CommandGroupConfig, Context, NewEmpty, PipelineData};
use nu_protocol::engine::Command;
use nu_protocol::{Config, Signature, SyntaxShape};

Loading…
Cancel
Save