From a1e21828d660535e2adfc2b1db66b90ba51f492e Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 29 Nov 2019 16:21:05 -0800 Subject: [PATCH] Fix tests --- src/commands/autoview.rs | 4 ++-- src/commands/cd.rs | 2 +- src/commands/next.rs | 2 +- src/commands/open.rs | 4 +--- src/commands/pick.rs | 2 +- src/commands/pivot.rs | 2 +- src/commands/plugin.rs | 4 +--- src/commands/post.rs | 2 +- src/commands/prev.rs | 2 +- src/commands/pwd.rs | 2 +- src/commands/split_by.rs | 4 +--- src/commands/split_column.rs | 2 +- src/commands/split_row.rs | 2 +- src/commands/t_sort_by.rs | 4 +--- src/commands/table.rs | 4 +--- src/commands/tags.rs | 2 +- src/commands/to_sqlite.rs | 4 +--- src/commands/to_toml.rs | 7 ++----- src/commands/to_url.rs | 2 +- src/commands/to_yaml.rs | 8 ++------ src/commands/trim.rs | 2 +- src/commands/version.rs | 2 +- src/commands/what.rs | 2 +- src/commands/which_.rs | 2 +- src/context.rs | 2 +- src/data/config.rs | 2 +- src/data/files.rs | 2 +- src/data/types.rs | 2 +- src/plugins/docker.rs | 5 +---- src/prelude.rs | 6 +++--- src/shell/shell.rs | 2 +- src/shell/shell_manager.rs | 2 +- tests/filter_str_tests.rs | 4 ++-- 33 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/commands/autoview.rs b/src/commands/autoview.rs index c515a3f506..5c8bf1c982 100644 --- a/src/commands/autoview.rs +++ b/src/commands/autoview.rs @@ -1,11 +1,11 @@ use crate::commands::{RawCommandArgs, WholeStreamCommand}; use crate::data::value; -use nu_parser::hir::{Expression, NamedArguments}; use crate::prelude::*; use futures::stream::TryStreamExt; +use nu_errors::ShellError; +use nu_parser::hir::{Expression, NamedArguments}; use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use std::sync::atomic::Ordering; -use nu_errors::{ShellError}; pub struct Autoview; diff --git a/src/commands/cd.rs b/src/commands/cd.rs index fe5381f27b..b96619caed 100644 --- a/src/commands/cd.rs +++ b/src/commands/cd.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{SyntaxShape, Signature}; use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; pub struct CD; diff --git a/src/commands/next.rs b/src/commands/next.rs index d815a3d8f3..2813da31dc 100644 --- a/src/commands/next.rs +++ b/src/commands/next.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; pub struct Next; diff --git a/src/commands/open.rs b/src/commands/open.rs index 8642d08c24..63b02355cb 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -1,10 +1,8 @@ use crate::commands::UnevaluatedCallInfo; use crate::data::value; use crate::prelude::*; -use nu_protocol::{ - CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{CallInfo, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::{AnchorLocation, Span}; use std::path::{Path, PathBuf}; diff --git a/src/commands/pick.rs b/src/commands/pick.rs index a8d075830a..a33fbda3b6 100644 --- a/src/commands/pick.rs +++ b/src/commands/pick.rs @@ -2,8 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::context::CommandRegistry; use crate::data::base::select_fields; use crate::prelude::*; -use nu_protocol::{Signature, SyntaxShape}; use nu_errors::ShellError; +use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/pivot.rs b/src/commands/pivot.rs index 5ab8c04f50..586fb71d0e 100644 --- a/src/commands/pivot.rs +++ b/src/commands/pivot.rs @@ -3,8 +3,8 @@ use crate::data::base::property_get::get_data_by_key; use crate::data::value; use crate::prelude::*; use crate::TaggedDictBuilder; -use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, Value}; use nu_source::{SpannedItem, Tagged}; pub struct Pivot; diff --git a/src/commands/plugin.rs b/src/commands/plugin.rs index b1bd267725..6c37b321a2 100644 --- a/src/commands/plugin.rs +++ b/src/commands/plugin.rs @@ -3,10 +3,8 @@ use crate::data::value; use crate::prelude::*; use derive_new::new; use log::trace; -use nu_protocol::{ - Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, ReturnValue, Signature, UntaggedValue, Value}; use serde::{self, Deserialize, Serialize}; use std::io::prelude::*; use std::io::BufReader; diff --git a/src/commands/post.rs b/src/commands/post.rs index 288f9c76be..63c445b6ee 100644 --- a/src/commands/post.rs +++ b/src/commands/post.rs @@ -3,10 +3,10 @@ use crate::data::value; use crate::prelude::*; use base64::encode; use mime::Mime; +use nu_errors::ShellError; use nu_protocol::{ CallInfo, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, }; -use nu_errors::ShellError; use nu_source::AnchorLocation; use std::path::PathBuf; use std::str::FromStr; diff --git a/src/commands/prev.rs b/src/commands/prev.rs index 79a8de4963..e2646716df 100644 --- a/src/commands/prev.rs +++ b/src/commands/prev.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{CommandAction, ReturnSuccess, Signature}; use crate::commands::WholeStreamCommand; diff --git a/src/commands/pwd.rs b/src/commands/pwd.rs index 390ed2dd6b..4ff64424d4 100644 --- a/src/commands/pwd.rs +++ b/src/commands/pwd.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{Signature}; use nu_errors::ShellError; +use nu_protocol::Signature; pub struct PWD; diff --git a/src/commands/split_by.rs b/src/commands/split_by.rs index e7a9540e58..876550db5e 100644 --- a/src/commands/split_by.rs +++ b/src/commands/split_by.rs @@ -1,10 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{ - ReturnSuccess, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, SpannedTypeName, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct SplitBy; diff --git a/src/commands/split_column.rs b/src/commands/split_column.rs index 110f9b2a28..8ed5a61d83 100644 --- a/src/commands/split_column.rs +++ b/src/commands/split_column.rs @@ -2,8 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; use log::trace; -use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/split_row.rs b/src/commands/split_row.rs index 0e6b702b6b..e0a803b713 100644 --- a/src/commands/split_row.rs +++ b/src/commands/split_row.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use log::trace; -use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue}; use nu_source::Tagged; #[derive(Deserialize)] diff --git a/src/commands/t_sort_by.rs b/src/commands/t_sort_by.rs index 222a545467..70bd635475 100644 --- a/src/commands/t_sort_by.rs +++ b/src/commands/t_sort_by.rs @@ -3,10 +3,8 @@ use crate::data::base::property_get::get_data_by_key; use crate::data::{value, TaggedDictBuilder, TaggedListBuilder}; use crate::prelude::*; use chrono::{DateTime, NaiveDate, Utc}; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::Tagged; pub struct TSortBy; diff --git a/src/commands/table.rs b/src/commands/table.rs index 1292b9419b..4fce36e437 100644 --- a/src/commands/table.rs +++ b/src/commands/table.rs @@ -2,10 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::data::value; use crate::format::TableView; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Table; diff --git a/src/commands/tags.rs b/src/commands/tags.rs index 17dd97573b..7ffed96455 100644 --- a/src/commands/tags.rs +++ b/src/commands/tags.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{Signature}; use nu_errors::ShellError; +use nu_protocol::Signature; pub struct Tags; diff --git a/src/commands/to_sqlite.rs b/src/commands/to_sqlite.rs index 5f395aa0d0..0237b53e58 100644 --- a/src/commands/to_sqlite.rs +++ b/src/commands/to_sqlite.rs @@ -1,10 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use hex::encode; -use nu_protocol::{ - Dictionary, Primitive, ReturnSuccess, Signature, UntaggedValue, Value, -}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, Primitive, ReturnSuccess, Signature, UntaggedValue, Value}; use rusqlite::{Connection, NO_PARAMS}; use std::io::Read; diff --git a/src/commands/to_toml.rs b/src/commands/to_toml.rs index 76b03aa89c..7504d7def6 100644 --- a/src/commands/to_toml.rs +++ b/src/commands/to_toml.rs @@ -1,10 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value, -}; -use nu_errors::{ShellError, CoerceInto}; - +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; pub struct ToTOML; diff --git a/src/commands/to_url.rs b/src/commands/to_url.rs index 1326561681..71f5db1554 100644 --- a/src/commands/to_url.rs +++ b/src/commands/to_url.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::data::value; use crate::prelude::*; -use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; pub struct ToURL; diff --git a/src/commands/to_yaml.rs b/src/commands/to_yaml.rs index 20ad7be45c..243ee80875 100644 --- a/src/commands/to_yaml.rs +++ b/src/commands/to_yaml.rs @@ -1,11 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ - Primitive, ReturnSuccess, Signature, UnspannedPathMember, - UntaggedValue, Value, -}; -use nu_errors::{ShellError, CoerceInto}; - +use nu_errors::{CoerceInto, ShellError}; +use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; pub struct ToYAML; diff --git a/src/commands/trim.rs b/src/commands/trim.rs index 264b8c68e0..3119fe511d 100644 --- a/src/commands/trim.rs +++ b/src/commands/trim.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{ReturnSuccess, Signature}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, Signature}; pub struct Trim; diff --git a/src/commands/version.rs b/src/commands/version.rs index 79f667ec5d..b07e37529f 100644 --- a/src/commands/version.rs +++ b/src/commands/version.rs @@ -1,8 +1,8 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; use indexmap::IndexMap; -use nu_protocol::{Dictionary, Signature, UntaggedValue}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, Signature, UntaggedValue}; pub struct Version; diff --git a/src/commands/what.rs b/src/commands/what.rs index a470b738f1..cf9f3c81c1 100644 --- a/src/commands/what.rs +++ b/src/commands/what.rs @@ -4,8 +4,8 @@ use crate::data::value; use crate::prelude::*; use futures::StreamExt; use futures_util::pin_mut; -use nu_protocol::{ReturnSuccess, ReturnValue, Signature}; use nu_errors::ShellError; +use nu_protocol::{ReturnSuccess, ReturnValue, Signature}; use nu_source::PrettyDebug; pub struct What; diff --git a/src/commands/which_.rs b/src/commands/which_.rs index e1459d2da2..933f1b77d0 100644 --- a/src/commands/which_.rs +++ b/src/commands/which_.rs @@ -1,7 +1,7 @@ use crate::commands::WholeStreamCommand; use crate::prelude::*; -use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; pub struct Which; diff --git a/src/context.rs b/src/context.rs index 0753d00f56..3696944130 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,10 +1,10 @@ use crate::commands::{command::CommandArgs, Command, UnevaluatedCallInfo}; use crate::env::host::Host; -use nu_parser::{hir, hir::syntax_shape::ExpandContext, hir::syntax_shape::SignatureRegistry}; use crate::shell::shell_manager::ShellManager; use crate::stream::{InputStream, OutputStream}; use indexmap::IndexMap; use nu_errors::ShellError; +use nu_parser::{hir, hir::syntax_shape::ExpandContext, hir::syntax_shape::SignatureRegistry}; use nu_protocol::{errln, Signature}; use nu_source::{Tag, Text}; use std::error::Error; diff --git a/src/data/config.rs b/src/data/config.rs index 7caa2b8826..9e0bdfcbea 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -4,8 +4,8 @@ use crate::prelude::*; use app_dirs::*; use indexmap::IndexMap; use log::trace; -use nu_protocol::{Dictionary, ShellTypeName, UntaggedValue, Value}; use nu_errors::ShellError; +use nu_protocol::{Dictionary, ShellTypeName, UntaggedValue, Value}; use serde::{Deserialize, Serialize}; use std::fs::{self, OpenOptions}; use std::io; diff --git a/src/data/files.rs b/src/data/files.rs index b7cde60cc1..aec410e0e5 100644 --- a/src/data/files.rs +++ b/src/data/files.rs @@ -1,7 +1,7 @@ use crate::data::TaggedDictBuilder; use crate::prelude::*; -use nu_protocol::{Value}; use nu_errors::ShellError; +use nu_protocol::Value; #[derive(Debug)] pub enum FileType { diff --git a/src/data/types.rs b/src/data/types.rs index 23ddb638b0..d140f31e22 100644 --- a/src/data/types.rs +++ b/src/data/types.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use log::trace; +use nu_errors::{CoerceInto, ShellError}; use nu_protocol::{Primitive, SpannedTypeName, UntaggedValue, Value}; -use nu_errors::{ShellError, CoerceInto}; use nu_source::Tagged; pub trait ExtractType: Sized { diff --git a/src/plugins/docker.rs b/src/plugins/docker.rs index fc483a5ecf..a2a80d6c11 100644 --- a/src/plugins/docker.rs +++ b/src/plugins/docker.rs @@ -48,10 +48,7 @@ fn process_docker_output(cmd_output: &str, tag: Tag) -> Result, Shell let mut dict = TaggedDictBuilder::new(&tag); for (i, v) in values.iter().enumerate() { - dict.insert( - header[i].to_string(), - value::string(v.trim().to_string()), - ); + dict.insert(header[i].to_string(), value::string(v.trim().to_string())); } output.push(dict.into_value()); diff --git a/src/prelude.rs b/src/prelude.rs index c5912ed264..35fa419c80 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -110,11 +110,11 @@ pub(crate) use futures::stream::BoxStream; pub(crate) use futures::{FutureExt, Stream, StreamExt}; pub(crate) use nu_protocol::{EvaluateTrait, MaybeOwned}; pub(crate) use nu_source::{ - b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, - PrettyDebugWithSource, Span, SpannedItem, Tag, TaggedItem, Text, + b, AnchorLocation, DebugDocBuilder, HasSpan, PrettyDebug, PrettyDebugWithSource, Span, + SpannedItem, Tag, TaggedItem, Text, }; pub(crate) use num_bigint::BigInt; -pub(crate) use num_traits::cast::{ToPrimitive}; +pub(crate) use num_traits::cast::ToPrimitive; pub(crate) use serde::Deserialize; pub(crate) use std::collections::VecDeque; pub(crate) use std::future::Future; diff --git a/src/shell/shell.rs b/src/shell/shell.rs index cfc233ba7e..e812e7b24e 100644 --- a/src/shell/shell.rs +++ b/src/shell/shell.rs @@ -3,9 +3,9 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use nu_errors::ShellError; use crate::prelude::*; use crate::stream::OutputStream; +use nu_errors::ShellError; use nu_source::Tagged; use std::path::PathBuf; diff --git a/src/shell/shell_manager.rs b/src/shell/shell_manager.rs index e63b21e884..6dd0a66a40 100644 --- a/src/shell/shell_manager.rs +++ b/src/shell/shell_manager.rs @@ -3,11 +3,11 @@ use crate::commands::cp::CopyArgs; use crate::commands::mkdir::MkdirArgs; use crate::commands::mv::MoveArgs; use crate::commands::rm::RemoveArgs; -use nu_errors::ShellError; use crate::prelude::*; use crate::shell::filesystem_shell::FilesystemShell; use crate::shell::shell::Shell; use crate::stream::OutputStream; +use nu_errors::ShellError; use nu_source::Tagged; use std::error::Error; use std::path::PathBuf; diff --git a/tests/filter_str_tests.rs b/tests/filter_str_tests.rs index a58c5439b6..fde3c77ee0 100644 --- a/tests/filter_str_tests.rs +++ b/tests/filter_str_tests.rs @@ -131,7 +131,7 @@ fn find_and_replaces() { cwd: dirs.test(), h::pipeline( r#" open sample.toml - | str fortune.teller.phone --find-replace [KATZ 5289] + | str fortune.teller.phone --find-replace [KATZ "5289"] | get fortune.teller.phone | echo $it "# @@ -157,7 +157,7 @@ fn find_and_replaces_without_passing_field() { r#" open sample.toml | get fortune.teller.phone - | str --find-replace [KATZ 5289] + | str --find-replace [KATZ "5289"] | echo $it "# ));