forked from extern/nushell
Move us away from mixing OOP and spreadsheet to just spreadsheet
This commit is contained in:
@ -238,7 +238,7 @@ impl ExternalCommand {
|
||||
if let Some(span) = span {
|
||||
return Err(ShellError::labeled_error(
|
||||
"External $it needs string data",
|
||||
"given object instead of string data",
|
||||
"given row instead of string data",
|
||||
span,
|
||||
));
|
||||
} else {
|
||||
@ -293,7 +293,7 @@ impl ExternalCommand {
|
||||
}
|
||||
return Err(ShellError::labeled_error(
|
||||
"External $it needs string data",
|
||||
"given object instead of string data",
|
||||
"given row instead of string data",
|
||||
span,
|
||||
));
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ fn to_bson(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
Value::Binary(x).simple_spanned(name_span),
|
||||
),
|
||||
_ => yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with BSON-compatible structure.span() from pipeline",
|
||||
"Expected a table with BSON-compatible structure.span() from pipeline",
|
||||
"requires BSON-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
@ -265,7 +265,7 @@ fn to_bson(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
}
|
||||
}
|
||||
_ => yield Err(ShellError::labeled_error(
|
||||
"Expected an object with BSON-compatible structure from pipeline",
|
||||
"Expected a table with BSON-compatible structure from pipeline",
|
||||
"requires BSON-compatible input",
|
||||
name_span))
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ fn to_csv(
|
||||
}
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with CSV-compatible structure.span() from pipeline",
|
||||
"Expected a table with CSV-compatible structure.span() from pipeline",
|
||||
"requires CSV-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
|
@ -100,7 +100,7 @@ fn to_json(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
Value::Primitive(Primitive::String(x)).simple_spanned(name_span),
|
||||
),
|
||||
_ => yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with JSON-compatible structure.span() from pipeline",
|
||||
"Expected a table with JSON-compatible structure.span() from pipeline",
|
||||
"requires JSON-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
@ -109,7 +109,7 @@ fn to_json(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
}
|
||||
}
|
||||
_ => yield Err(ShellError::labeled_error(
|
||||
"Expected an object with JSON-compatible structure from pipeline",
|
||||
"Expected a table with JSON-compatible structure from pipeline",
|
||||
"requires JSON-compatible input",
|
||||
name_span))
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ fn sqlite_input_stream_to_bytes(
|
||||
other => {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("Expected object, found {:?}", other),
|
||||
format!("Expected row, found {:?}", other),
|
||||
))
|
||||
}
|
||||
}
|
||||
@ -207,7 +207,7 @@ fn to_sqlite(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStre
|
||||
Ok(out) => yield ReturnSuccess::value(out),
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Expected an object with SQLite-compatible structure.span() from pipeline",
|
||||
"Expected a table with SQLite-compatible structure.span() from pipeline",
|
||||
"requires SQLite-compatible input",
|
||||
name_span,
|
||||
))
|
||||
|
@ -95,7 +95,7 @@ fn to_toml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
Value::Primitive(Primitive::String(x)).simple_spanned(name_span),
|
||||
),
|
||||
_ => yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with TOML-compatible structure.span() from pipeline",
|
||||
"Expected a table with TOML-compatible structure.span() from pipeline",
|
||||
"requires TOML-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
@ -104,7 +104,7 @@ fn to_toml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
}
|
||||
}
|
||||
_ => yield Err(ShellError::labeled_error(
|
||||
"Expected an object with TOML-compatible structure from pipeline",
|
||||
"Expected a table with TOML-compatible structure from pipeline",
|
||||
"requires TOML-compatible input",
|
||||
name_span))
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ fn to_string_helper(v: &Value) -> Result<String, ShellError> {
|
||||
Value::Primitive(Primitive::Date(d)) => Ok(d.to_string()),
|
||||
Value::Primitive(Primitive::Bytes(b)) => Ok(format!("{}", b)),
|
||||
Value::Primitive(Primitive::Boolean(_)) => Ok(v.as_string()?),
|
||||
Value::List(_) => return Ok(String::from("[list list]")),
|
||||
Value::Object(_) => return Ok(String::from("[object]")),
|
||||
Value::List(_) => return Ok(String::from("[table]")),
|
||||
Value::Object(_) => return Ok(String::from("[row]")),
|
||||
Value::Primitive(Primitive::String(s)) => return Ok(s.to_string()),
|
||||
_ => Err(ShellError::string("Unexpected value")),
|
||||
}
|
||||
@ -152,7 +152,7 @@ fn to_tsv(
|
||||
}
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with TSV-compatible structure.span() from pipeline",
|
||||
"Expected a table with TSV-compatible structure.span() from pipeline",
|
||||
"requires TSV-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
|
@ -96,7 +96,7 @@ fn to_yaml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
Value::Primitive(Primitive::String(x)).simple_spanned(name_span),
|
||||
),
|
||||
_ => yield Err(ShellError::labeled_error_with_secondary(
|
||||
"Expected an object with YAML-compatible structure.span() from pipeline",
|
||||
"Expected a table with YAML-compatible structure.span() from pipeline",
|
||||
"requires YAML-compatible input",
|
||||
name_span,
|
||||
"originates from here".to_string(),
|
||||
@ -105,7 +105,7 @@ fn to_yaml(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream
|
||||
}
|
||||
}
|
||||
_ => yield Err(ShellError::labeled_error(
|
||||
"Expected an object with YAML-compatible structure from pipeline",
|
||||
"Expected a table with YAML-compatible structure from pipeline",
|
||||
"requires YAML-compatible input",
|
||||
name_span))
|
||||
}
|
||||
|
@ -504,11 +504,11 @@ impl Value {
|
||||
.map(|e| e.source(&b.source).to_string()),
|
||||
"; ",
|
||||
),
|
||||
Value::Object(_) => format!("[{}]", self.type_name()),
|
||||
Value::Object(_) => format!("[table: 1 row]"),
|
||||
Value::List(l) => format!(
|
||||
"[{} {}]",
|
||||
"[table: {} {}]",
|
||||
l.len(),
|
||||
if l.len() == 1 { "item" } else { "items" }
|
||||
if l.len() == 1 { "row" } else { "rows" }
|
||||
),
|
||||
Value::Binary(_) => format!("<binary>"),
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ impl Add {
|
||||
}
|
||||
},
|
||||
None => Err(ShellError::string(
|
||||
"add needs a field when adding a value to an object",
|
||||
"add needs a column name when adding a value to a table",
|
||||
)),
|
||||
},
|
||||
x => Err(ShellError::string(format!(
|
||||
@ -46,7 +46,8 @@ impl Plugin for Add {
|
||||
.desc("Add a new field to the table.")
|
||||
.required("Field", SyntaxType::String)
|
||||
.required("Value", SyntaxType::String)
|
||||
.rest(SyntaxType::String).filter())
|
||||
.rest(SyntaxType::String)
|
||||
.filter())
|
||||
}
|
||||
|
||||
fn begin_filter(&mut self, call_info: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
|
||||
|
@ -23,12 +23,12 @@ impl Edit {
|
||||
Some(v) => return Ok(v),
|
||||
None => {
|
||||
return Err(ShellError::string(
|
||||
"edit could not find place to insert field",
|
||||
"edit could not find place to insert column",
|
||||
))
|
||||
}
|
||||
},
|
||||
None => Err(ShellError::string(
|
||||
"edit needs a field when adding a value to an object",
|
||||
"edit needs a column when changing a value in a table",
|
||||
)),
|
||||
},
|
||||
x => Err(ShellError::string(format!(
|
||||
@ -42,7 +42,7 @@ impl Edit {
|
||||
impl Plugin for Edit {
|
||||
fn config(&mut self) -> Result<Signature, ShellError> {
|
||||
Ok(Signature::build("edit")
|
||||
.desc("Edit an existing field to have a new value.")
|
||||
.desc("Edit an existing column to have a new value.")
|
||||
.required("Field", SyntaxType::String)
|
||||
.required("Value", SyntaxType::String)
|
||||
.filter())
|
||||
|
@ -102,7 +102,7 @@ impl Inc {
|
||||
}
|
||||
}
|
||||
None => Err(ShellError::string(
|
||||
"inc needs a field when incrementing a value in an object",
|
||||
"inc needs a field when incrementing a column in a table",
|
||||
)),
|
||||
},
|
||||
x => Err(ShellError::string(format!(
|
||||
@ -116,7 +116,7 @@ impl Inc {
|
||||
impl Plugin for Inc {
|
||||
fn config(&mut self) -> Result<Signature, ShellError> {
|
||||
Ok(Signature::build("inc")
|
||||
.desc("Increment a value or version. Optional use the field of a table.")
|
||||
.desc("Increment a value or version. Optionally use the column of a table.")
|
||||
.switch("major")
|
||||
.switch("minor")
|
||||
.switch("patch")
|
||||
|
@ -153,7 +153,7 @@ impl Str {
|
||||
}
|
||||
None => Err(ShellError::string(format!(
|
||||
"{}: {}",
|
||||
"str needs a field when applying it to a value in an object",
|
||||
"str needs a column when applied to a value in a row",
|
||||
Str::usage()
|
||||
))),
|
||||
},
|
||||
|
Reference in New Issue
Block a user