Remove old nushell/merge engine-q

This commit is contained in:
JT
2022-02-07 14:54:06 -05:00
parent 10c4c50f1f
commit d70d91e559
430 changed files with 14543 additions and 7865 deletions

View File

@ -1,36 +1,16 @@
[package]
authors = ["The Nu Project Contributors"]
description = "A version incrementer plugin for Nushell"
<<<<<<< HEAD
edition = "2018"
license = "MIT"
name = "nu_plugin_inc"
version = "0.43.0"
=======
edition = "2021"
license = "MIT"
name = "nu_plugin_inc"
version = "0.1.0"
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
version = "0.59.0"
[lib]
doctest = false
[dependencies]
<<<<<<< HEAD
nu-errors = { path="../nu-errors", version = "0.43.0" }
nu-plugin = { path="../nu-plugin", version = "0.43.0" }
nu-protocol = { path="../nu-protocol", version = "0.43.0" }
nu-source = { path="../nu-source", version = "0.43.0" }
nu-test-support = { path="../nu-test-support", version = "0.43.0" }
nu-value-ext = { path="../nu-value-ext", version = "0.43.0" }
nu-plugin = { path="../nu-plugin", version = "0.59.0" }
nu-protocol = { path="../nu-protocol", version = "0.59.0", features = ["plugin"]}
semver = "0.11.0"
[build-dependencies]
=======
nu-plugin = { path="../nu-plugin", version = "0.1.0" }
nu-protocol = { path="../nu-protocol", version = "0.1.0", features = ["plugin"]}
semver = "0.11.0"
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce

View File

@ -1,12 +1,5 @@
<<<<<<< HEAD
use nu_errors::ShellError;
use nu_protocol::{did_you_mean, ColumnPath, Primitive, ShellTypeName, UntaggedValue, Value};
use nu_source::{span_for_spanned_list, HasSpan, SpannedItem, Tagged};
use nu_value_ext::{get_data_by_column_path, ValueExt};
=======
use nu_plugin::LabeledError;
use nu_protocol::{Span, Value};
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
#[derive(Debug, Eq, PartialEq)]
pub enum Action {
@ -23,10 +16,6 @@ pub enum SemVerAction {
#[derive(Default)]
pub struct Inc {
<<<<<<< HEAD
pub field: Option<Tagged<ColumnPath>>,
=======
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
pub error: Option<String>,
pub action: Option<Action>,
}
@ -36,25 +25,17 @@ impl Inc {
Default::default()
}
<<<<<<< HEAD
fn apply(&self, input: &str) -> UntaggedValue {
=======
fn apply(&self, input: &str, head: Span) -> Value {
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
match &self.action {
Some(Action::SemVerAction(act_on)) => {
let mut ver = match semver::Version::parse(input) {
Ok(parsed_ver) => parsed_ver,
<<<<<<< HEAD
Err(_) => return UntaggedValue::string(input.to_string()),
=======
Err(_) => {
return Value::String {
val: input.to_string(),
span: head,
}
}
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
};
match act_on {
@ -63,13 +44,6 @@ impl Inc {
SemVerAction::Patch => ver.increment_patch(),
}
<<<<<<< HEAD
UntaggedValue::string(ver.to_string())
}
Some(Action::Default) | None => match input.parse::<u64>() {
Ok(v) => UntaggedValue::string((v + 1).to_string()),
Err(_) => UntaggedValue::string(input),
=======
Value::String {
val: ver.to_string(),
span: head,
@ -84,7 +58,6 @@ impl Inc {
val: input.to_string(),
span: head,
},
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
},
}
}
@ -109,76 +82,6 @@ impl Inc {
"Usage: inc field [--major|--minor|--patch]"
}
<<<<<<< HEAD
pub fn inc(&self, value: Value) -> Result<Value, ShellError> {
match &value.value {
UntaggedValue::Primitive(Primitive::Int(i)) => {
Ok(UntaggedValue::int(i + 1).into_value(value.tag()))
}
UntaggedValue::Primitive(Primitive::Filesize(b)) => {
Ok(UntaggedValue::filesize(b + 1_u64).into_value(value.tag()))
}
UntaggedValue::Primitive(Primitive::String(ref s)) => {
Ok(self.apply(s).into_value(value.tag()))
}
UntaggedValue::Table(values) => {
if values.len() == 1 {
Ok(UntaggedValue::Table(vec![self.inc(values[0].clone())?])
.into_value(value.tag()))
} else {
Err(ShellError::type_error(
"incrementable value",
value.type_name().spanned(value.span()),
))
}
}
UntaggedValue::Row(_) => match self.field {
Some(ref f) => {
let fields = f.clone();
let replace_for = get_data_by_column_path(
&value,
f,
move |obj_source, column_path_tried, _| match did_you_mean(
obj_source,
column_path_tried.as_string(),
) {
Some(suggestions) => ShellError::labeled_error(
"Unknown column",
format!("did you mean '{}'?", suggestions[0]),
span_for_spanned_list(fields.iter().map(|p| p.span)),
),
None => ShellError::labeled_error(
"Unknown column",
"row does not contain this column",
span_for_spanned_list(fields.iter().map(|p| p.span)),
),
},
);
let got = replace_for?;
let replacement = self.inc(got)?;
value
.replace_data_at_column_path(f, replacement.value.into_untagged_value())
.ok_or_else(|| {
ShellError::labeled_error(
"inc could not find field to replace",
"column name",
value.tag(),
)
})
}
None => Err(ShellError::untagged_runtime_error(
"inc needs a field when incrementing a column in a table",
)),
},
_ => Err(ShellError::type_error(
"incrementable value",
value.type_name().spanned(value.span()),
)),
=======
pub fn inc(&self, head: Span, value: &Value) -> Result<Value, LabeledError> {
match value {
Value::Int { val, span } => Ok(Value::Int {
@ -199,7 +102,6 @@ impl Inc {
span: Some(head),
})
}
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}
}
}
@ -207,17 +109,6 @@ impl Inc {
#[cfg(test)]
mod tests {
mod semver {
<<<<<<< HEAD
use crate::inc::SemVerAction;
use crate::Inc;
use nu_test_support::value::string;
#[test]
fn major() {
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Major);
assert_eq!(inc.apply("0.1.3"), string("1.0.0").value);
=======
use nu_protocol::{Span, Value};
use crate::inc::SemVerAction;
@ -232,16 +123,10 @@ mod tests {
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Major);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}
#[test]
fn minor() {
<<<<<<< HEAD
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Minor);
assert_eq!(inc.apply("0.1.3"), string("0.2.0").value);
=======
let expected = Value::String {
val: "0.2.0".to_string(),
span: Span::test_data(),
@ -249,16 +134,10 @@ mod tests {
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Minor);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}
#[test]
fn patch() {
<<<<<<< HEAD
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Patch);
assert_eq!(inc.apply("0.1.3"), string("0.1.4").value);
=======
let expected = Value::String {
val: "0.1.4".to_string(),
span: Span::test_data(),
@ -266,7 +145,6 @@ mod tests {
let mut inc = Inc::new();
inc.for_semver(SemVerAction::Patch);
assert_eq!(inc.apply("0.1.3", Span::test_data()), expected)
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}
}
}

View File

@ -2,37 +2,3 @@ mod inc;
mod nu;
pub use inc::Inc;
<<<<<<< HEAD
#[cfg(test)]
mod tests {
use super::Inc;
use crate::inc::Action;
use nu_protocol::Value;
use nu_value_ext::ValueExt;
impl Inc {
pub fn expect_action(&self, action: Action) {
match &self.action {
Some(set) if set == &action => {}
Some(_) => panic!("\nUnexpected action"),
None => panic!("\nAction not found."),
}
}
pub fn expect_field(&self, field: Value) {
let field = match field.as_column_path() {
Ok(column_path) => column_path,
Err(_) => panic!("\nExpected a ColumnPath",),
};
match &self.field {
Some(column_path) if column_path == &field => {}
Some(_) => panic!("\nUnexpected field."),
None => panic!("\nField not found."),
}
}
}
}
=======
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce

View File

@ -1,14 +1,6 @@
<<<<<<< HEAD
use nu_plugin::serve_plugin;
use nu_plugin_inc::Inc;
fn main() {
serve_plugin(&mut Inc::new())
=======
use nu_plugin::{serve_plugin, CapnpSerializer};
use nu_plugin_inc::Inc;
fn main() {
serve_plugin(&mut Inc::new(), CapnpSerializer {})
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}

View File

@ -1,22 +1,3 @@
<<<<<<< HEAD
#[cfg(test)]
mod tests;
use crate::inc::{Action, SemVerAction};
use crate::Inc;
use nu_errors::ShellError;
use nu_plugin::Plugin;
use nu_protocol::{
CallInfo, Primitive, ReturnSuccess, ReturnValue, ShellTypeName, Signature, SyntaxShape,
UntaggedValue, Value,
};
use nu_source::{HasSpan, SpannedItem};
use nu_value_ext::ValueExt;
impl Plugin for Inc {
fn config(&mut self) -> Result<Signature, ShellError> {
Ok(Signature::build("inc")
=======
use crate::inc::SemVerAction;
use crate::Inc;
use nu_plugin::{EvaluatedCall, LabeledError, Plugin};
@ -25,7 +6,6 @@ use nu_protocol::{Signature, Value};
impl Plugin for Inc {
fn signature(&self) -> Vec<Signature> {
vec![Signature::build("inc")
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
.desc("Increment a value or version. Optionally use the column of a table.")
.switch(
"major",
@ -41,59 +21,6 @@ impl Plugin for Inc {
"patch",
"increment the patch version (eg 1.2.1 -> 1.2.2)",
Some('p'),
<<<<<<< HEAD
)
.rest("rest", SyntaxShape::ColumnPath, "the column(s) to update")
.filter())
}
fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
if call_info.args.has("major") {
self.for_semver(SemVerAction::Major);
}
if call_info.args.has("minor") {
self.for_semver(SemVerAction::Minor);
}
if call_info.args.has("patch") {
self.for_semver(SemVerAction::Patch);
}
if let Some(args) = call_info.args.positional {
for arg in args {
match arg {
table @ Value {
value: UntaggedValue::Primitive(Primitive::ColumnPath(_)),
..
} => {
self.field = Some(table.as_column_path()?);
}
value => {
return Err(ShellError::type_error(
"table",
value.type_name().spanned(value.span()),
))
}
}
}
}
if self.action.is_none() {
self.action = Some(Action::Default);
}
match &self.error {
Some(reason) => Err(ShellError::untagged_runtime_error(format!(
"{}: {}",
reason,
Inc::usage()
))),
None => Ok(vec![]),
}
}
fn filter(&mut self, input: Value) -> Result<Vec<ReturnValue>, ShellError> {
Ok(vec![ReturnSuccess::value(self.inc(input)?)])
=======
)]
}
@ -118,6 +45,5 @@ impl Plugin for Inc {
}
self.inc(call.head, input)
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
}
}