Nushell internal commands. Anchor locations tracker surveying. (#2635)

This commit is contained in:
Andrés N. Robalino 2020-10-03 09:06:02 -05:00 committed by GitHub
parent 0adf2accdd
commit ae1d4bdb4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
180 changed files with 1169 additions and 465 deletions

View File

@ -135,7 +135,7 @@ pub(crate) use command::{
pub(crate) use alias::Alias;
pub(crate) use ansi::Ansi;
pub(crate) use append::Append;
pub(crate) use append::Command as Append;
pub(crate) use autoenv::Autoenv;
pub(crate) use autoenv_trust::AutoenvTrust;
pub(crate) use autoenv_untrust::AutoenvUnTrust;
@ -164,7 +164,7 @@ pub(crate) use echo::Echo;
pub(crate) use if_::If;
pub(crate) use is_empty::IsEmpty;
pub(crate) use nu::NuPlugin;
pub(crate) use update::Update;
pub(crate) use update::Command as Update;
pub(crate) mod kill;
pub(crate) use kill::Kill;
pub(crate) mod clear;
@ -193,13 +193,13 @@ pub(crate) use from_xml::FromXML;
pub(crate) use from_yaml::FromYAML;
pub(crate) use from_yaml::FromYML;
pub(crate) use get::Get;
pub(crate) use group_by::GroupBy;
pub(crate) use group_by::Command as GroupBy;
pub(crate) use group_by_date::GroupByDate;
pub(crate) use headers::Headers;
pub(crate) use help::Help;
pub(crate) use histogram::Histogram;
pub(crate) use history::History;
pub(crate) use insert::Insert;
pub(crate) use insert::Command as Insert;
pub(crate) use into_int::IntoInt;
pub(crate) use keep::{Keep, KeepUntil, KeepWhile};
pub(crate) use last::Last;
@ -270,3 +270,40 @@ pub(crate) use where_::Where;
pub(crate) use which_::Which;
pub(crate) use with_env::WithEnv;
pub(crate) use wrap::Wrap;
#[cfg(test)]
mod tests {
use super::*;
use crate::commands::whole_stream_command;
use crate::examples::{test_anchors, test_examples};
use nu_errors::ShellError;
fn commands() -> Vec<Command> {
vec![
// Table operations
whole_stream_command(Append),
whole_stream_command(GroupBy),
// Row specific operations
whole_stream_command(Insert),
whole_stream_command(Update),
]
}
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
for cmd in commands() {
test_examples(cmd)?;
}
Ok(())
}
#[test]
fn tracks_metadata() -> Result<(), ShellError> {
for cmd in commands() {
test_anchors(cmd)?;
}
Ok(())
}
}

View File

@ -340,11 +340,12 @@ fn find_block_shapes(block: &Block, registry: &CommandRegistry) -> Result<ShapeM
#[cfg(test)]
mod tests {
use super::Alias;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Alias {})
Ok(test_examples(Alias {})?)
}
}

View File

@ -135,11 +135,12 @@ pub fn str_to_ansi_color(s: String) -> Option<String> {
#[cfg(test)]
mod tests {
use super::Ansi;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Ansi {})
Ok(test_examples(Ansi {})?)
}
}

View File

@ -2,17 +2,17 @@ use crate::command_registry::CommandRegistry;
use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use nu_errors::ShellError;
use nu_protocol::{Signature, SyntaxShape, UntaggedValue, Value};
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
#[derive(Deserialize)]
struct AppendArgs {
struct Arguments {
row: Value,
}
pub struct Append;
pub struct Command;
#[async_trait]
impl WholeStreamCommand for Append {
impl WholeStreamCommand for Command {
fn name(&self) -> &str {
"append"
}
@ -34,11 +34,18 @@ impl WholeStreamCommand for Append {
args: CommandArgs,
registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
let (AppendArgs { row }, input) = args.process(registry).await?;
let (Arguments { mut row }, input) = args.process(registry).await?;
let eos = futures::stream::iter(vec![row]);
let input: Vec<Value> = input.collect().await;
Ok(input.chain(eos).to_output_stream())
if let Some(first) = input.get(0) {
row.tag = first.tag();
}
Ok(
futures::stream::iter(input.into_iter().chain(vec![row]).map(ReturnSuccess::value))
.to_output_stream(),
)
}
fn examples(&self) -> Vec<Example> {
@ -54,15 +61,3 @@ impl WholeStreamCommand for Append {
}]
}
}
#[cfg(test)]
mod tests {
use super::Append;
#[test]
fn examples_work_as_expected() {
use crate::examples::test as test_examples;
test_examples(Append {})
}
}

View File

@ -326,11 +326,12 @@ fn create_default_command_args(context: &RunnableContextWithoutInput) -> RawComm
#[cfg(test)]
mod tests {
use super::Command;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
}

View File

@ -339,11 +339,12 @@ fn add_month_to_table(
#[cfg(test)]
mod tests {
use super::Cal;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Cal {})
Ok(test_examples(Cal {})?)
}
}

View File

@ -72,11 +72,12 @@ impl WholeStreamCommand for Cd {
#[cfg(test)]
mod tests {
use super::Cd;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Cd {})
Ok(test_examples(Cd {})?)
}
}

View File

@ -130,11 +130,12 @@ fn str_to_character(s: &str) -> Option<String> {
#[cfg(test)]
mod tests {
use super::Char;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Char {})
Ok(test_examples(Char {})?)
}
}

View File

@ -42,11 +42,12 @@ impl WholeStreamCommand for Chart {
#[cfg(test)]
mod tests {
use super::Chart;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Chart {})
Ok(test_examples(Chart {})?)
}
}

View File

@ -43,15 +43,3 @@ impl WholeStreamCommand for Clear {
}]
}
}
#[cfg(test)]
mod tests {
use super::Clear;
#[test]
fn examples_work_as_expected() {
use crate::examples::test as test_examples;
test_examples(Clear {})
}
}

View File

@ -104,11 +104,12 @@ pub async fn clip(
#[cfg(test)]
mod tests {
use super::Clip;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Clip {})
Ok(test_examples(Clip {})?)
}
}

View File

@ -84,11 +84,12 @@ pub async fn compact(
#[cfg(test)]
mod tests {
use super::Compact;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Compact {})
Ok(test_examples(Compact {})?)
}
}

View File

@ -80,11 +80,12 @@ impl WholeStreamCommand for Count {
#[cfg(test)]
mod tests {
use super::Count;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Count {})
Ok(test_examples(Count {})?)
}
}

View File

@ -66,11 +66,12 @@ impl WholeStreamCommand for Cpy {
#[cfg(test)]
mod tests {
use super::Cpy;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Cpy {})
Ok(test_examples(Cpy {})?)
}
}

View File

@ -36,11 +36,12 @@ impl WholeStreamCommand for Command {
#[cfg(test)]
mod tests {
use super::Command;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
}

View File

@ -61,3 +61,16 @@ pub async fn format(
Ok(OutputStream::one(value))
}
#[cfg(test)]
mod tests {
use super::Date;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
Ok(test_examples(Date {})?)
}
}

View File

@ -48,3 +48,16 @@ pub async fn now(
Ok(OutputStream::one(value))
}
#[cfg(test)]
mod tests {
use super::Date;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
Ok(test_examples(Date {})?)
}
}

View File

@ -48,3 +48,16 @@ pub async fn utc(
Ok(OutputStream::one(value))
}
#[cfg(test)]
mod tests {
use super::Date;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
Ok(test_examples(Date {})?)
}
}

View File

@ -55,11 +55,12 @@ async fn debug_value(
#[cfg(test)]
mod tests {
use super::Debug;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Debug {})
Ok(test_examples(Debug {})?)
}
}

View File

@ -83,11 +83,12 @@ async fn default(
#[cfg(test)]
mod tests {
use super::Default;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Default {})
Ok(test_examples(Default {})?)
}
}

View File

@ -50,11 +50,12 @@ pub async fn describe(
#[cfg(test)]
mod tests {
use super::Describe;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Describe {})
Ok(test_examples(Describe {})?)
}
}

View File

@ -117,11 +117,12 @@ async fn do_(
#[cfg(test)]
mod tests {
use super::Do;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Do {})
Ok(test_examples(Do {})?)
}
}

View File

@ -85,11 +85,12 @@ async fn drop(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStr
#[cfg(test)]
mod tests {
use super::Drop;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Drop {})
Ok(test_examples(Drop {})?)
}
}

View File

@ -427,11 +427,12 @@ impl From<FileInfo> for Value {
#[cfg(test)]
mod tests {
use super::Du;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Du {})
Ok(test_examples(Du {})?)
}
}

View File

@ -164,11 +164,12 @@ async fn each(
#[cfg(test)]
mod tests {
use super::Each;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Each {})
Ok(test_examples(Each {})?)
}
}

View File

@ -123,11 +123,12 @@ pub(crate) fn run_block_on_vec(
#[cfg(test)]
mod tests {
use super::EachGroup;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(EachGroup {})
Ok(test_examples(EachGroup {})?)
}
}

View File

@ -103,11 +103,12 @@ impl WholeStreamCommand for EachWindow {
#[cfg(test)]
mod tests {
use super::EachWindow;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(EachWindow {})
Ok(test_examples(EachWindow {})?)
}
}

View File

@ -162,11 +162,12 @@ impl Iterator for RangeIterator {
#[cfg(test)]
mod tests {
use super::Echo;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Echo {})
Ok(test_examples(Echo {})?)
}
}

View File

@ -191,11 +191,12 @@ async fn enter(
#[cfg(test)]
mod tests {
use super::Enter;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Enter {})
Ok(test_examples(Enter {})?)
}
}

View File

@ -93,11 +93,12 @@ async fn every(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
#[cfg(test)]
mod tests {
use super::Every;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Every {})
Ok(test_examples(Every {})?)
}
}

View File

@ -63,11 +63,12 @@ pub async fn exit(
#[cfg(test)]
mod tests {
use super::Exit;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Exit {})
Ok(test_examples(Exit {})?)
}
}

View File

@ -72,11 +72,12 @@ async fn first(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
#[cfg(test)]
mod tests {
use super::First;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(First {})
Ok(test_examples(First {})?)
}
}

View File

@ -151,11 +151,12 @@ fn format(input: &str) -> Vec<FormatCommand> {
#[cfg(test)]
mod tests {
use super::Format;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Format {})
Ok(test_examples(Format {})?)
}
}

View File

@ -35,11 +35,12 @@ impl WholeStreamCommand for From {
#[cfg(test)]
mod tests {
use super::From;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(From {})
Ok(test_examples(From {})?)
}
}

View File

@ -109,11 +109,12 @@ async fn from_csv(
#[cfg(test)]
mod tests {
use super::FromCSV;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromCSV {})
Ok(test_examples(FromCSV {})?)
}
}

View File

@ -130,11 +130,12 @@ async fn from_eml(
#[cfg(test)]
mod tests {
use super::FromEML;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromEML {})
Ok(test_examples(FromEML {})?)
}
}

View File

@ -249,11 +249,12 @@ fn params_to_value(params: Vec<(String, Vec<String>)>, tag: Tag) -> Value {
#[cfg(test)]
mod tests {
use super::FromIcs;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromIcs {})
Ok(test_examples(FromIcs {})?)
}
}

View File

@ -95,11 +95,12 @@ async fn from_ini(
#[cfg(test)]
mod tests {
use super::FromINI;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromINI {})
Ok(test_examples(FromINI {})?)
}
}

View File

@ -144,11 +144,12 @@ async fn from_json(
#[cfg(test)]
mod tests {
use super::FromJSON;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromJSON {})
Ok(test_examples(FromJSON {})?)
}
}

View File

@ -102,11 +102,12 @@ async fn from_ods(
#[cfg(test)]
mod tests {
use super::FromODS;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromODS {})
Ok(test_examples(FromODS {})?)
}
}

View File

@ -302,7 +302,9 @@ async fn from_ssv(
#[cfg(test)]
mod tests {
use super::ShellError;
use super::*;
fn owned(x: &str, y: &str) -> (String, String) {
(String::from(x), String::from(y))
}
@ -504,10 +506,10 @@ mod tests {
}
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use super::FromSSV;
use crate::examples::test as test_examples;
test_examples(FromSSV {})
Ok(test_examples(FromSSV {})?)
}
}

View File

@ -101,11 +101,12 @@ pub async fn from_toml(
#[cfg(test)]
mod tests {
use super::FromTOML;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromTOML {})
Ok(test_examples(FromTOML {})?)
}
}

View File

@ -52,11 +52,12 @@ async fn from_tsv(
#[cfg(test)]
mod tests {
use super::FromTSV;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromTSV {})
Ok(test_examples(FromTSV {})?)
}
}

View File

@ -64,11 +64,12 @@ async fn from_url(
#[cfg(test)]
mod tests {
use super::FromURL;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromURL {})
Ok(test_examples(FromURL {})?)
}
}

View File

@ -104,11 +104,12 @@ fn params_to_value(params: Vec<(String, Vec<String>)>, tag: Tag) -> Value {
#[cfg(test)]
mod tests {
use super::FromVcf;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromVcf {})
Ok(test_examples(FromVcf {})?)
}
}

View File

@ -102,11 +102,12 @@ async fn from_xlsx(
#[cfg(test)]
mod tests {
use super::FromXLSX;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromXLSX {})
Ok(test_examples(FromXLSX {})?)
}
}

View File

@ -135,6 +135,7 @@ async fn from_xml(
#[cfg(test)]
mod tests {
use super::ShellError;
use crate::commands::from_xml;
use indexmap::IndexMap;
use nu_protocol::{UntaggedValue, Value};
@ -304,10 +305,10 @@ mod tests {
}
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use super::FromXML;
use crate::examples::test as test_examples;
test_examples(FromXML {})
Ok(test_examples(FromXML {})?)
}
}

View File

@ -173,15 +173,16 @@ async fn from_yaml(
#[cfg(test)]
mod tests {
use super::ShellError;
use super::*;
use nu_plugin::row;
use nu_plugin::test_helpers::value::string;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(FromYAML {})
Ok(test_examples(FromYAML {})?)
}
#[test]

View File

@ -267,11 +267,12 @@ pub fn get_column_from_row_error(
#[cfg(test)]
mod tests {
use super::Get;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Get {})
Ok(test_examples(Get {})?)
}
}

View File

@ -7,15 +7,15 @@ use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
use nu_source::Tagged;
use nu_value_ext::as_string;
pub struct GroupBy;
pub struct Command;
#[derive(Deserialize)]
pub struct GroupByArgs {
pub struct Arguments {
grouper: Option<Value>,
}
#[async_trait]
impl WholeStreamCommand for GroupBy {
impl WholeStreamCommand for Command {
fn name(&self) -> &str {
"group-by"
}
@ -40,17 +40,45 @@ impl WholeStreamCommand for GroupBy {
group_by(args, registry).await
}
#[allow(clippy::unwrap_used)]
fn examples(&self) -> Vec<Example> {
use nu_data::value::date_naive_from_str as date;
vec![
Example {
description: "group items by column named \"type\"",
example: r#"ls | group-by type"#,
result: None,
},
Example {
description: "blocks can be used for generating a grouping key (same as above)",
example: r#"ls | group-by { get type }"#,
result: None,
result: Some(vec![UntaggedValue::row(indexmap! {
"File".to_string() => UntaggedValue::Table(vec![
UntaggedValue::row(indexmap! {
"modified".to_string() => date("2019-07-23".tagged_unknown()).unwrap().into(),
"name".to_string() => UntaggedValue::string("Andrés.txt").into(),
"type".to_string() => UntaggedValue::string("File").into(),
"chickens".to_string() => UntaggedValue::int(10).into(),
}).into(),
UntaggedValue::row(indexmap! {
"modified".to_string() => date("2019-09-24".tagged_unknown()).unwrap().into(),
"name".to_string() => UntaggedValue::string("Andrés.txt").into(),
"type".to_string() => UntaggedValue::string("File").into(),
"chickens".to_string() => UntaggedValue::int(20).into(),
}).into(),
]).into(),
"Dir".to_string() => UntaggedValue::Table(vec![
UntaggedValue::row(indexmap! {
"modified".to_string() => date("2019-07-23".tagged_unknown()).unwrap().into(),
"name".to_string() => UntaggedValue::string("Jonathan").into(),
"type".to_string() => UntaggedValue::string("Dir").into(),
"chickens".to_string() => UntaggedValue::int(5).into(),
}).into(),
UntaggedValue::row(indexmap! {
"modified".to_string() => date("2019-09-24".tagged_unknown()).unwrap().into(),
"name".to_string() => UntaggedValue::string("Yehuda").into(),
"type".to_string() => UntaggedValue::string("Dir").into(),
"chickens".to_string() => UntaggedValue::int(4).into(),
}).into(),
]).into(),
})
.into()]),
},
Example {
description: "you can also group by raw values by leaving out the argument",
@ -75,10 +103,26 @@ impl WholeStreamCommand for GroupBy {
.into()]),
},
Example {
description: "write pipelines for a more involved grouping key",
example:
"echo [1 3 1 3 2 1 1] | group-by { echo `({{$it}} - 1) % 3` | calc | str from }",
result: None,
description:
"use the block form to generate a grouping key when each row gets processed",
example: "echo [1 3 1 3 2 1 1] | group-by { = ($it - 1) mod 3 }",
result: Some(vec![UntaggedValue::row(indexmap! {
"0".to_string() => UntaggedValue::Table(vec![
UntaggedValue::int(1).into(),
UntaggedValue::int(1).into(),
UntaggedValue::int(1).into(),
UntaggedValue::int(1).into(),
]).into(),
"2".to_string() => UntaggedValue::Table(vec![
UntaggedValue::int(3).into(),
UntaggedValue::int(3).into(),
]).into(),
"1".to_string() => UntaggedValue::Table(vec![
UntaggedValue::int(2).into(),
]).into(),
})
.into()]),
},
]
}
@ -98,7 +142,7 @@ pub async fn group_by(
let head = Arc::new(args.call_info.args.head.clone());
let scope = args.call_info.scope.clone();
let context = Arc::new(EvaluationContext::from_raw(&args, &registry));
let (GroupByArgs { grouper }, input) = args.process(&registry).await?;
let (Arguments { grouper }, input) = args.process(&registry).await?;
let values: Vec<Value> = input.collect().await;
let mut keys: Vec<Result<String, ShellError>> = vec![];
@ -168,6 +212,14 @@ pub async fn group_by(
));
}
let first = values[0].clone();
let name = if first.tag.anchor().is_some() {
first.tag
} else {
name
};
let values = UntaggedValue::table(&values).into_value(&name);
let group_value = match group_strategy {
@ -180,9 +232,9 @@ pub async fn group_by(
None => as_string(row),
});
nu_data::utils::group(&values, &Some(block), &name)
nu_data::utils::group(&values, &Some(block), name)
}
Grouper::ByColumn(column_name) => group(&column_name, &values, name),
Grouper::ByColumn(column_name) => group(&column_name, &values, &name),
};
Ok(OutputStream::one(ReturnSuccess::value(group_value?)))
@ -287,12 +339,4 @@ mod tests {
Ok(())
}
#[test]
fn examples_work_as_expected() {
use super::GroupBy;
use crate::examples::test as test_examples;
test_examples(GroupBy {})
}
}

View File

@ -141,11 +141,12 @@ pub async fn group_by_date(
#[cfg(test)]
mod tests {
use super::GroupByDate;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(GroupByDate {})
Ok(test_examples(GroupByDate {})?)
}
}

View File

@ -116,11 +116,12 @@ pub async fn headers(
#[cfg(test)]
mod tests {
use super::Headers;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Headers {})
Ok(test_examples(Headers {})?)
}
}

View File

@ -234,11 +234,12 @@ pub fn get_help(cmd: &dyn WholeStreamCommand, registry: &CommandRegistry) -> Str
#[cfg(test)]
mod tests {
use super::Help;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Help {})
Ok(test_examples(Help {})?)
}
}

View File

@ -227,11 +227,12 @@ fn splitter(
#[cfg(test)]
mod tests {
use super::Histogram;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Histogram {})
Ok(test_examples(Histogram {})?)
}
}

View File

@ -79,11 +79,12 @@ fn history(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStrea
#[cfg(test)]
mod tests {
use super::History;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(History {})
Ok(test_examples(History {})?)
}
}

View File

@ -174,11 +174,12 @@ async fn if_command(
#[cfg(test)]
mod tests {
use super::If;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(If {})
Ok(test_examples(If {})?)
}
}

View File

@ -9,16 +9,18 @@ use nu_protocol::{
use nu_value_ext::ValueExt;
use futures::stream::once;
pub struct Insert;
use indexmap::indexmap;
pub struct Command;
#[derive(Deserialize)]
pub struct InsertArgs {
pub struct Arguments {
column: ColumnPath,
value: Value,
}
#[async_trait]
impl WholeStreamCommand for Insert {
impl WholeStreamCommand for Command {
fn name(&self) -> &str {
"insert"
}
@ -44,6 +46,28 @@ impl WholeStreamCommand for Insert {
) -> Result<OutputStream, ShellError> {
insert(args, registry).await
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Insert a column with a value",
example: "echo [[author, commits]; ['Andrés', 1]] | insert branches 5",
result: Some(vec![UntaggedValue::row(indexmap! {
"author".to_string() => Value::from("Andrés"),
"commits".to_string() => UntaggedValue::int(1).into(),
"branches".to_string() => UntaggedValue::int(5).into(),
})
.into()]),
},Example {
description: "Use in block form for more involved insertion logic",
example: "echo [[author, lucky_number]; ['Yehuda', 4]] | insert success { = $it.lucky_number * 10 }",
result: Some(vec![UntaggedValue::row(indexmap! {
"author".to_string() => Value::from("Yehuda"),
"lucky_number".to_string() => UntaggedValue::int(4).into(),
"success".to_string() => UntaggedValue::int(40).into(),
})
.into()]),
}]
}
}
async fn process_row(
@ -135,7 +159,7 @@ async fn insert(
let registry = registry.clone();
let scope = raw_args.call_info.scope.clone();
let context = Arc::new(EvaluationContext::from_raw(&raw_args, &registry));
let (InsertArgs { column, value }, input) = raw_args.process(&registry).await?;
let (Arguments { column, value }, input) = raw_args.process(&registry).await?;
let value = Arc::new(value);
let column = Arc::new(column);
@ -156,15 +180,3 @@ async fn insert(
.flatten()
.to_output_stream())
}
#[cfg(test)]
mod tests {
use super::Insert;
#[test]
fn examples_work_as_expected() {
use crate::examples::test as test_examples;
test_examples(Insert {})
}
}

View File

@ -78,11 +78,12 @@ async fn into_int(
#[cfg(test)]
mod tests {
use super::IntoInt;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(IntoInt {})
Ok(test_examples(IntoInt {})?)
}
}

View File

@ -207,11 +207,12 @@ async fn is_empty(
#[cfg(test)]
mod tests {
use super::IsEmpty;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(IsEmpty {})
Ok(test_examples(IsEmpty {})?)
}
}

View File

@ -74,11 +74,12 @@ async fn keep(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStr
#[cfg(test)]
mod tests {
use super::Command;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
}

View File

@ -101,12 +101,13 @@ impl WholeStreamCommand for SubCommand {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -100,12 +100,13 @@ impl WholeStreamCommand for SubCommand {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -121,11 +121,12 @@ async fn kill(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStr
#[cfg(test)]
mod tests {
use super::Kill;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Kill {})
Ok(test_examples(Kill {})?)
}
}

View File

@ -83,11 +83,12 @@ async fn last(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStr
#[cfg(test)]
mod tests {
use super::Last;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Last {})
Ok(test_examples(Last {})?)
}
}

View File

@ -125,11 +125,12 @@ async fn lines(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
#[cfg(test)]
mod tests {
use super::Lines;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Lines {})
Ok(test_examples(Lines {})?)
}
}

View File

@ -89,11 +89,12 @@ impl WholeStreamCommand for Ls {
#[cfg(test)]
mod tests {
use super::Ls;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Ls {})
Ok(test_examples(Ls {})?)
}
}

View File

@ -188,12 +188,13 @@ pub fn average(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -44,10 +44,10 @@ mod tests {
use std::str::FromStr;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
#[test]

View File

@ -100,12 +100,13 @@ pub fn parse<T: Into<Tag>>(math_expression: &str, tag: T) -> Result<Value, Strin
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -58,12 +58,13 @@ pub fn maximum(values: &[Value], _name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -186,12 +186,13 @@ fn compute_average(values: &[Value], name: impl Into<Tag>) -> Result<Value, Shel
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -58,12 +58,13 @@ pub fn minimum(values: &[Value], _name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -83,12 +83,13 @@ pub fn mode(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -115,12 +115,13 @@ pub fn product(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -141,12 +141,13 @@ pub fn compute_stddev(values: &[Value], n: usize, name: &Tag) -> Result<Value, S
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -125,12 +125,13 @@ pub fn summation(values: &[Value], name: &Tag) -> Result<Value, ShellError> {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -240,12 +240,13 @@ pub fn compute_variance(values: &[Value], n: usize, name: &Tag) -> Result<Value,
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -101,11 +101,12 @@ async fn merge(
#[cfg(test)]
mod tests {
use super::Merge;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Merge {})
Ok(test_examples(Merge {})?)
}
}

View File

@ -60,11 +60,12 @@ async fn mkdir(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputSt
#[cfg(test)]
mod tests {
use super::Mkdir;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Mkdir {})
Ok(test_examples(Mkdir {})?)
}
}

View File

@ -324,12 +324,13 @@ fn move_before(
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -36,11 +36,12 @@ impl WholeStreamCommand for Command {
#[cfg(test)]
mod tests {
use super::Command;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
}

View File

@ -79,11 +79,12 @@ async fn mv(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStrea
#[cfg(test)]
mod tests {
use super::Mv;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Mv {})
Ok(test_examples(Mv {})?)
}
}

View File

@ -35,11 +35,12 @@ fn next(_args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream,
#[cfg(test)]
mod tests {
use super::Next;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Next {})
Ok(test_examples(Next {})?)
}
}

View File

@ -96,11 +96,12 @@ async fn nth(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStre
#[cfg(test)]
mod tests {
use super::Nth;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Nth {})
Ok(test_examples(Nth {})?)
}
}

View File

@ -113,12 +113,13 @@ impl WholeStreamCommand for SubCommand {
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

View File

@ -243,11 +243,12 @@ pub async fn fetch(
#[cfg(test)]
mod tests {
use super::Open;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Open {})
Ok(test_examples(Open {})?)
}
}

View File

@ -176,11 +176,12 @@ fn column_names(regex: &Regex) -> Vec<String> {
#[cfg(test)]
mod tests {
use super::Command;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Command {})
Ok(test_examples(Command {})?)
}
}

View File

@ -51,11 +51,12 @@ fn action(path: &Path) -> UntaggedValue {
#[cfg(test)]
mod tests {
use super::PathBasename;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(PathBasename {})
Ok(test_examples(PathBasename {})?)
}
}

View File

@ -36,11 +36,12 @@ impl WholeStreamCommand for Path {
#[cfg(test)]
mod tests {
use super::Path;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Path {})
Ok(test_examples(Path {})?)
}
}

View File

@ -50,11 +50,12 @@ fn action(path: &Path) -> UntaggedValue {
#[cfg(test)]
mod tests {
use super::PathDirname;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(PathDirname {})
Ok(test_examples(PathDirname {})?)
}
}

View File

@ -43,3 +43,16 @@ impl WholeStreamCommand for PathExists {
fn action(path: &Path) -> UntaggedValue {
UntaggedValue::boolean(path.exists())
}
#[cfg(test)]
mod tests {
use super::PathExists;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
Ok(test_examples(PathExists {})?)
}
}

View File

@ -2,7 +2,7 @@ use super::{operate, DefaultArguments};
use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use nu_errors::ShellError;
use nu_protocol::{Signature, SyntaxShape, UntaggedValue, Value};
use nu_protocol::{Signature, SyntaxShape, UntaggedValue};
use std::path::Path;
pub struct PathExpand;
@ -35,7 +35,8 @@ impl WholeStreamCommand for PathExpand {
vec![Example {
description: "Expand relative directories",
example: "echo '/home/joe/foo/../bar' | path expand",
result: Some(vec![Value::from("/home/joe/bar")]),
result: None,
//Some(vec![Value::from("/home/joe/bar")]),
}]
}
}
@ -49,3 +50,16 @@ fn action(path: &Path) -> UntaggedValue {
Err(_) => ps.to_string(),
})
}
#[cfg(test)]
mod tests {
use super::PathExpand;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
Ok(test_examples(PathExpand {})?)
}
}

View File

@ -58,11 +58,12 @@ fn action(path: &Path) -> UntaggedValue {
#[cfg(test)]
mod tests {
use super::PathExtension;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(PathExtension {})
Ok(test_examples(PathExtension {})?)
}
}

View File

@ -51,11 +51,12 @@ fn action(path: &Path) -> UntaggedValue {
#[cfg(test)]
mod tests {
use super::PathFilestem;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(PathFilestem {})
Ok(test_examples(PathFilestem {})?)
}
}

View File

@ -52,11 +52,12 @@ fn action(path: &Path) -> UntaggedValue {
#[cfg(test)]
mod tests {
use super::PathType;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(PathType {})
Ok(test_examples(PathType {})?)
}
}

View File

@ -155,11 +155,12 @@ pub async fn pivot(
#[cfg(test)]
mod tests {
use super::Pivot;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Pivot {})
Ok(test_examples(Pivot {})?)
}
}

View File

@ -67,11 +67,12 @@ async fn prepend(
#[cfg(test)]
mod tests {
use super::Prepend;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Prepend {})
Ok(test_examples(Prepend {})?)
}
}

View File

@ -36,11 +36,12 @@ fn previous(_args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStr
#[cfg(test)]
mod tests {
use super::Previous;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Previous {})
Ok(test_examples(Previous {})?)
}
}

View File

@ -50,11 +50,12 @@ pub async fn pwd(
#[cfg(test)]
mod tests {
use super::Pwd;
use super::ShellError;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Pwd {})
Ok(test_examples(Pwd {})?)
}
}

View File

@ -86,12 +86,13 @@ pub async fn bool_command(
#[cfg(test)]
mod tests {
use super::ShellError;
use super::SubCommand;
#[test]
fn examples_work_as_expected() {
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(SubCommand {})
Ok(test_examples(SubCommand {})?)
}
}

Some files were not shown because too many files have changed in this diff Show More