diff --git a/crates/nu-ansi-term/examples/rgb_colors.rs b/crates/nu-ansi-term/examples/rgb_colors.rs index 96efddf790..4657d401f4 100644 --- a/crates/nu-ansi-term/examples/rgb_colors.rs +++ b/crates/nu-ansi-term/examples/rgb_colors.rs @@ -15,7 +15,7 @@ fn main() { let g = (col * 255 / WIDTH) as u8; let b = 128; - print!("{}", Style::default().on(Color::RGB(r, g, b)).paint(" ")); + print!("{}", Style::default().on(Color::Rgb(r, g, b)).paint(" ")); } println!(); diff --git a/crates/nu-ansi-term/src/ansi.rs b/crates/nu-ansi-term/src/ansi.rs index 74e3456e89..02c339f967 100644 --- a/crates/nu-ansi-term/src/ansi.rs +++ b/crates/nu-ansi-term/src/ansi.rs @@ -103,7 +103,7 @@ impl Color { Color::Cyan => write!(f, "36"), Color::White => write!(f, "37"), Color::Fixed(num) => write!(f, "38;5;{}", &num), - Color::RGB(r, g, b) => write!(f, "38;2;{};{};{}", &r, &g, &b), + Color::Rgb(r, g, b) => write!(f, "38;2;{};{};{}", &r, &g, &b), Color::DarkGray => write!(f, "90"), Color::LightRed => write!(f, "91"), Color::LightGreen => write!(f, "92"), @@ -128,7 +128,7 @@ impl Color { Color::Cyan => write!(f, "46"), Color::White => write!(f, "47"), Color::Fixed(num) => write!(f, "48;5;{}", &num), - Color::RGB(r, g, b) => write!(f, "48;2;{};{};{}", &r, &g, &b), + Color::Rgb(r, g, b) => write!(f, "48;2;{};{};{}", &r, &g, &b), Color::DarkGray => write!(f, "100"), Color::LightRed => write!(f, "101"), Color::LightGreen => write!(f, "102"), @@ -372,10 +372,10 @@ mod test { test!(fixed: Fixed(100); "hi" => "\x1B[38;5;100mhi\x1B[0m"); test!(fixed_on_purple: Fixed(100).on(Purple); "hi" => "\x1B[45;38;5;100mhi\x1B[0m"); test!(fixed_on_fixed: Fixed(100).on(Fixed(200)); "hi" => "\x1B[48;5;200;38;5;100mhi\x1B[0m"); - test!(rgb: RGB(70,130,180); "hi" => "\x1B[38;2;70;130;180mhi\x1B[0m"); - test!(rgb_on_blue: RGB(70,130,180).on(Blue); "hi" => "\x1B[44;38;2;70;130;180mhi\x1B[0m"); - test!(blue_on_rgb: Blue.on(RGB(70,130,180)); "hi" => "\x1B[48;2;70;130;180;34mhi\x1B[0m"); - test!(rgb_on_rgb: RGB(70,130,180).on(RGB(5,10,15)); "hi" => "\x1B[48;2;5;10;15;38;2;70;130;180mhi\x1B[0m"); + test!(rgb: Rgb(70,130,180); "hi" => "\x1B[38;2;70;130;180mhi\x1B[0m"); + test!(rgb_on_blue: Rgb(70,130,180).on(Blue); "hi" => "\x1B[44;38;2;70;130;180mhi\x1B[0m"); + test!(blue_on_rgb: Blue.on(Rgb(70,130,180)); "hi" => "\x1B[48;2;70;130;180;34mhi\x1B[0m"); + test!(rgb_on_rgb: Rgb(70,130,180).on(Rgb(5,10,15)); "hi" => "\x1B[48;2;5;10;15;38;2;70;130;180mhi\x1B[0m"); test!(bold: Style::new().bold(); "hi" => "\x1B[1mhi\x1B[0m"); test!(underline: Style::new().underline(); "hi" => "\x1B[4mhi\x1B[0m"); test!(bunderline: Style::new().bold().underline(); "hi" => "\x1B[1;4mhi\x1B[0m"); diff --git a/crates/nu-ansi-term/src/debug.rs b/crates/nu-ansi-term/src/debug.rs index c28f868781..1dcde52bec 100644 --- a/crates/nu-ansi-term/src/debug.rs +++ b/crates/nu-ansi-term/src/debug.rs @@ -112,7 +112,7 @@ mod test { test!(both: style().bold().italic() => "Style { bold, italic }"); test!(red: Red.normal() => "Style { fg(Red) }"); - test!(redblue: Red.normal().on(RGB(3, 2, 4)) => "Style { fg(Red), on(RGB(3, 2, 4)) }"); + test!(redblue: Red.normal().on(Rgb(3, 2, 4)) => "Style { fg(Red), on(Rgb(3, 2, 4)) }"); test!(everything: Red.on(Blue).blink().bold().dimmed().hidden().italic().reverse().strikethrough().underline() => diff --git a/crates/nu-ansi-term/src/display.rs b/crates/nu-ansi-term/src/display.rs index 9bc8aede29..36118a0c9c 100644 --- a/crates/nu-ansi-term/src/display.rs +++ b/crates/nu-ansi-term/src/display.rs @@ -11,7 +11,7 @@ use std::ops::Deref; /// display that string. `ANSIString` and `ANSIByteString` are aliases for /// this type on `str` and `\[u8]`, respectively. #[derive(PartialEq, Debug)] -pub struct ANSIGenericString<'a, S: 'a + ToOwned + ?Sized> +pub struct AnsiGenericString<'a, S: 'a + ToOwned + ?Sized> where ::Owned: fmt::Debug, { @@ -30,12 +30,12 @@ where /// let clone_string = plain_string.clone(); /// assert_eq!(clone_string, plain_string); /// ``` -impl<'a, S: 'a + ToOwned + ?Sized> Clone for ANSIGenericString<'a, S> +impl<'a, S: 'a + ToOwned + ?Sized> Clone for AnsiGenericString<'a, S> where ::Owned: fmt::Debug, { - fn clone(&self) -> ANSIGenericString<'a, S> { - ANSIGenericString { + fn clone(&self) -> AnsiGenericString<'a, S> { + AnsiGenericString { style: self.style, string: self.string.clone(), } @@ -85,26 +85,26 @@ where /// let plain_string = ANSIString::from("a plain string"); /// assert_eq!(&*plain_string, "a plain string"); /// ``` -pub type ANSIString<'a> = ANSIGenericString<'a, str>; +pub type AnsiString<'a> = AnsiGenericString<'a, str>; -/// An `ANSIByteString` represents a formatted series of bytes. Use -/// `ANSIByteString` when styling text with an unknown encoding. -pub type ANSIByteString<'a> = ANSIGenericString<'a, [u8]>; +/// An `AnsiByteString` represents a formatted series of bytes. Use +/// `AnsiByteString` when styling text with an unknown encoding. +pub type AnsiByteString<'a> = AnsiGenericString<'a, [u8]>; -impl<'a, I, S: 'a + ToOwned + ?Sized> From for ANSIGenericString<'a, S> +impl<'a, I, S: 'a + ToOwned + ?Sized> From for AnsiGenericString<'a, S> where I: Into>, ::Owned: fmt::Debug, { - fn from(input: I) -> ANSIGenericString<'a, S> { - ANSIGenericString { + fn from(input: I) -> AnsiGenericString<'a, S> { + AnsiGenericString { string: input.into(), style: Style::default(), } } } -impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericString<'a, S> +impl<'a, S: 'a + ToOwned + ?Sized> AnsiGenericString<'a, S> where ::Owned: fmt::Debug, { @@ -119,7 +119,7 @@ where } } -impl<'a, S: 'a + ToOwned + ?Sized> Deref for ANSIGenericString<'a, S> +impl<'a, S: 'a + ToOwned + ?Sized> Deref for AnsiGenericString<'a, S> where ::Owned: fmt::Debug, { @@ -130,32 +130,32 @@ where } } -/// A set of `ANSIGenericString`s collected together, in order to be +/// A set of `AnsiGenericStrings`s collected together, in order to be /// written with a minimum of control characters. #[derive(Debug, PartialEq)] -pub struct ANSIGenericStrings<'a, S: 'a + ToOwned + ?Sized>(pub &'a [ANSIGenericString<'a, S>]) +pub struct AnsiGenericStrings<'a, S: 'a + ToOwned + ?Sized>(pub &'a [AnsiGenericString<'a, S>]) where ::Owned: fmt::Debug, S: PartialEq; -/// A set of `ANSIString`s collected together, in order to be written with a +/// A set of `AnsiString`s collected together, in order to be written with a /// minimum of control characters. -pub type ANSIStrings<'a> = ANSIGenericStrings<'a, str>; +pub type AnsiStrings<'a> = AnsiGenericStrings<'a, str>; -/// A function to construct an `ANSIStrings` instance. +/// A function to construct an `AnsiStrings` instance. #[allow(non_snake_case)] -pub fn ANSIStrings<'a>(arg: &'a [ANSIString<'a>]) -> ANSIStrings<'a> { - ANSIGenericStrings(arg) +pub fn AnsiStrings<'a>(arg: &'a [AnsiString<'a>]) -> AnsiStrings<'a> { + AnsiGenericStrings(arg) } -/// A set of `ANSIByteString`s collected together, in order to be +/// A set of `AnsiByteString`s collected together, in order to be /// written with a minimum of control characters. -pub type ANSIByteStrings<'a> = ANSIGenericStrings<'a, [u8]>; +pub type AnsiByteStrings<'a> = AnsiGenericStrings<'a, [u8]>; /// A function to construct an `ANSIByteStrings` instance. #[allow(non_snake_case)] -pub fn ANSIByteStrings<'a>(arg: &'a [ANSIByteString<'a>]) -> ANSIByteStrings<'a> { - ANSIGenericStrings(arg) +pub fn ANSIByteStrings<'a>(arg: &'a [AnsiByteString<'a>]) -> AnsiByteStrings<'a> { + AnsiGenericStrings(arg) } // ---- paint functions ---- @@ -163,12 +163,12 @@ pub fn ANSIByteStrings<'a>(arg: &'a [ANSIByteString<'a>]) -> ANSIByteStrings<'a> impl Style { /// Paints the given text with this color, returning an ANSI string. #[must_use] - pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> + pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> AnsiGenericString<'a, S> where I: Into>, ::Owned: fmt::Debug, { - ANSIGenericString { + AnsiGenericString { string: input.into(), style: self, } @@ -185,12 +185,12 @@ impl Color { /// println!("{}", Blue.paint("da ba dee")); /// ``` #[must_use] - pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> + pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> AnsiGenericString<'a, S> where I: Into>, ::Owned: fmt::Debug, { - ANSIGenericString { + AnsiGenericString { string: input.into(), style: self.normal(), } @@ -199,14 +199,14 @@ impl Color { // ---- writers for individual ANSI strings ---- -impl<'a> fmt::Display for ANSIString<'a> { +impl<'a> fmt::Display for AnsiString<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let w: &mut dyn fmt::Write = f; self.write_to_any(w) } } -impl<'a> ANSIByteString<'a> { +impl<'a> AnsiByteString<'a> { /// Write an `ANSIByteString` to an `io::Write`. This writes the escape /// sequences for the associated `Style` around the bytes. pub fn write_to(&self, w: &mut W) -> io::Result<()> { @@ -215,7 +215,7 @@ impl<'a> ANSIByteString<'a> { } } -impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericString<'a, S> +impl<'a, S: 'a + ToOwned + ?Sized> AnsiGenericString<'a, S> where ::Owned: fmt::Debug, &'a S: AsRef<[u8]>, @@ -229,14 +229,14 @@ where // ---- writers for combined ANSI strings ---- -impl<'a> fmt::Display for ANSIStrings<'a> { +impl<'a> fmt::Display for AnsiStrings<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let f: &mut dyn fmt::Write = f; self.write_to_any(f) } } -impl<'a> ANSIByteStrings<'a> { +impl<'a> AnsiByteStrings<'a> { /// Write `ANSIByteStrings` to an `io::Write`. This writes the minimal /// escape sequences for the associated `Style`s around each set of /// bytes. @@ -246,7 +246,7 @@ impl<'a> ANSIByteStrings<'a> { } } -impl<'a, S: 'a + ToOwned + ?Sized + PartialEq> ANSIGenericStrings<'a, S> +impl<'a, S: 'a + ToOwned + ?Sized + PartialEq> AnsiGenericStrings<'a, S> where ::Owned: fmt::Debug, &'a S: AsRef<[u8]>, @@ -289,7 +289,7 @@ where #[cfg(test)] mod tests { - pub use super::super::ANSIStrings; + pub use super::super::AnsiStrings; pub use crate::style::Color::*; pub use crate::style::Style; @@ -297,7 +297,7 @@ mod tests { fn no_control_codes_for_plain() { let one = Style::default().paint("one"); let two = Style::default().paint("two"); - let output = format!("{}", ANSIStrings(&[one, two])); + let output = format!("{}", AnsiStrings(&[one, two])); assert_eq!(&*output, "onetwo"); } } diff --git a/crates/nu-ansi-term/src/style.rs b/crates/nu-ansi-term/src/style.rs index f0194031b1..05fb00cbde 100644 --- a/crates/nu-ansi-term/src/style.rs +++ b/crates/nu-ansi-term/src/style.rs @@ -365,7 +365,7 @@ pub enum Color { Fixed(u8), /// A 24-bit RGB color, as specified by ISO-8613-3. - RGB(u8, u8, u8), + Rgb(u8, u8, u8), } impl Color { diff --git a/crates/nu-ansi-term/src/util.rs b/crates/nu-ansi-term/src/util.rs index 65a7b552a0..653e9fc3af 100644 --- a/crates/nu-ansi-term/src/util.rs +++ b/crates/nu-ansi-term/src/util.rs @@ -1,12 +1,12 @@ -use crate::display::{ANSIString, ANSIStrings}; +use crate::display::{AnsiString, AnsiStrings}; use std::ops::Deref; /// Return a substring of the given ANSIStrings sequence, while keeping the formatting. pub fn sub_string<'a>( start: usize, len: usize, - strs: &ANSIStrings<'a>, -) -> Vec> { + strs: &AnsiStrings<'a>, +) -> Vec> { let mut vec = Vec::new(); let mut pos = start; let mut len_rem = len; @@ -39,7 +39,7 @@ pub fn sub_string<'a>( } /// Return a concatenated copy of `strs` without the formatting, as an allocated `String`. -pub fn unstyle(strs: &ANSIStrings) -> String { +pub fn unstyle(strs: &AnsiStrings) -> String { let mut s = String::new(); for i in strs.0.iter() { @@ -50,7 +50,7 @@ pub fn unstyle(strs: &ANSIStrings) -> String { } /// Return the unstyled length of ANSIStrings. This is equaivalent to `unstyle(strs).len()`. -pub fn unstyled_len(strs: &ANSIStrings) -> usize { +pub fn unstyled_len(strs: &AnsiStrings) -> usize { let mut l = 0; for i in strs.0.iter() { l += i.deref().len(); @@ -70,7 +70,7 @@ mod test { Red.paint("-second"), White.paint("-third"), ]; - let a = ANSIStrings(&l); + let a = AnsiStrings(&l); assert_eq!(unstyle(&a), "first-second-third"); assert_eq!(unstyled_len(&a), 18); diff --git a/crates/nu-command/src/commands.rs b/crates/nu-command/src/commands.rs index c3773afedb..9e742a4e08 100644 --- a/crates/nu-command/src/commands.rs +++ b/crates/nu-command/src/commands.rs @@ -184,21 +184,21 @@ pub(crate) use first::First; pub(crate) use flatten::Command as Flatten; pub(crate) use format::{FileSize, Format}; pub(crate) use from::From; -pub(crate) use from_csv::FromCSV; -pub(crate) use from_eml::FromEML; +pub(crate) use from_csv::FromCsv; +pub(crate) use from_eml::FromEml; pub(crate) use from_ics::FromIcs; -pub(crate) use from_ini::FromINI; -pub(crate) use from_json::FromJSON; -pub(crate) use from_ods::FromODS; -pub(crate) use from_ssv::FromSSV; -pub(crate) use from_toml::FromTOML; -pub(crate) use from_tsv::FromTSV; -pub(crate) use from_url::FromURL; +pub(crate) use from_ini::FromIni; +pub(crate) use from_json::FromJson; +pub(crate) use from_ods::FromOds; +pub(crate) use from_ssv::FromSsv; +pub(crate) use from_toml::FromToml; +pub(crate) use from_tsv::FromTsv; +pub(crate) use from_url::FromUrl; pub(crate) use from_vcf::FromVcf; -pub(crate) use from_xlsx::FromXLSX; -pub(crate) use from_xml::FromXML; -pub(crate) use from_yaml::FromYAML; -pub(crate) use from_yaml::FromYML; +pub(crate) use from_xlsx::FromXlsx; +pub(crate) use from_xml::FromXml; +pub(crate) use from_yaml::FromYaml; +pub(crate) use from_yaml::FromYml; pub(crate) use get::Command as Get; pub(crate) use group_by::Command as GroupBy; pub(crate) use group_by_date::GroupByDate; @@ -272,15 +272,15 @@ pub(crate) use table::Table; pub(crate) use tags::Tags; pub(crate) use termsize::TermSize; pub(crate) use to::To; -pub(crate) use to_csv::ToCSV; -pub(crate) use to_html::ToHTML; -pub(crate) use to_json::ToJSON; +pub(crate) use to_csv::ToCsv; +pub(crate) use to_html::ToHtml; +pub(crate) use to_json::ToJson; pub(crate) use to_md::Command as ToMarkdown; -pub(crate) use to_toml::ToTOML; -pub(crate) use to_tsv::ToTSV; -pub(crate) use to_url::ToURL; -pub(crate) use to_xml::ToXML; -pub(crate) use to_yaml::ToYAML; +pub(crate) use to_toml::ToToml; +pub(crate) use to_tsv::ToTsv; +pub(crate) use to_url::ToUrl; +pub(crate) use to_xml::ToXml; +pub(crate) use to_yaml::ToYaml; pub(crate) use touch::Touch; pub(crate) use uniq::Uniq; pub(crate) use url_::{UrlCommand, UrlHost, UrlPath, UrlQuery, UrlScheme}; diff --git a/crates/nu-command/src/commands/default_context.rs b/crates/nu-command/src/commands/default_context.rs index 5a945fabc2..06590f7e92 100644 --- a/crates/nu-command/src/commands/default_context.rs +++ b/crates/nu-command/src/commands/default_context.rs @@ -190,30 +190,30 @@ pub fn create_default_context(interactive: bool) -> Result, } #[async_trait] -impl WholeStreamCommand for FromCSV { +impl WholeStreamCommand for FromCsv { fn name(&self) -> &str { "from csv" } @@ -71,7 +71,7 @@ async fn from_csv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( - FromCSVArgs { + FromCsvArgs { noheaders, separator, }, @@ -105,13 +105,13 @@ async fn from_csv(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromCSV; + use super::FromCsv; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromCSV {}) + test_examples(FromCsv {}) } } diff --git a/crates/nu-command/src/commands/from_eml.rs b/crates/nu-command/src/commands/from_eml.rs index d1026de672..0e3bcca82e 100644 --- a/crates/nu-command/src/commands/from_eml.rs +++ b/crates/nu-command/src/commands/from_eml.rs @@ -6,18 +6,18 @@ use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder, UntaggedValue}; use nu_source::Tagged; -pub struct FromEML; +pub struct FromEml; const DEFAULT_BODY_PREVIEW: usize = 50; #[derive(Deserialize, Clone)] -pub struct FromEMLArgs { +pub struct FromEmlArgs { #[serde(rename(deserialize = "preview-body"))] preview_body: Option>, } #[async_trait] -impl WholeStreamCommand for FromEML { +impl WholeStreamCommand for FromEml { fn name(&self) -> &str { "from eml" } @@ -75,7 +75,7 @@ fn headerfieldvalue_to_value(tag: &Tag, value: &HeaderFieldValue) -> UntaggedVal async fn from_eml(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); - let (eml_args, input): (FromEMLArgs, _) = args.process().await?; + let (eml_args, input): (FromEmlArgs, _) = args.process().await?; let value = input.collect_string(tag.clone()).await?; let body_preview = eml_args @@ -121,13 +121,13 @@ async fn from_eml(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromEML; + use super::FromEml; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromEML {}) + test_examples(FromEml {}) } } diff --git a/crates/nu-command/src/commands/from_ini.rs b/crates/nu-command/src/commands/from_ini.rs index 4ddc8e7684..97bd56fc9d 100644 --- a/crates/nu-command/src/commands/from_ini.rs +++ b/crates/nu-command/src/commands/from_ini.rs @@ -4,10 +4,10 @@ use nu_errors::ShellError; use nu_protocol::{Primitive, Signature, TaggedDictBuilder, UntaggedValue, Value}; use std::collections::HashMap; -pub struct FromINI; +pub struct FromIni; #[async_trait] -impl WholeStreamCommand for FromINI { +impl WholeStreamCommand for FromIni { fn name(&self) -> &str { "from ini" } @@ -86,13 +86,13 @@ async fn from_ini(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromINI; + use super::FromIni; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromINI {}) + test_examples(FromIni {}) } } diff --git a/crates/nu-command/src/commands/from_json.rs b/crates/nu-command/src/commands/from_json.rs index f43ce18162..dc0d9091ee 100644 --- a/crates/nu-command/src/commands/from_json.rs +++ b/crates/nu-command/src/commands/from_json.rs @@ -3,15 +3,15 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Primitive, ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue, Value}; -pub struct FromJSON; +pub struct FromJson; #[derive(Deserialize)] -pub struct FromJSONArgs { +pub struct FromJsonArgs { objects: bool, } #[async_trait] -impl WholeStreamCommand for FromJSON { +impl WholeStreamCommand for FromJson { fn name(&self) -> &str { "from json" } @@ -71,7 +71,7 @@ pub fn from_json_string_to_value(s: String, tag: impl Into) -> nu_json::Res async fn from_json(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); - let (FromJSONArgs { objects }, input) = args.process().await?; + let (FromJsonArgs { objects }, input) = args.process().await?; let concat_string = input.collect_string(name_tag.clone()).await?; let string_clone: Vec<_> = concat_string.item.lines().map(|x| x.to_string()).collect(); @@ -135,13 +135,13 @@ async fn from_json(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromJSON; + use super::FromJson; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromJSON {}) + test_examples(FromJson {}) } } diff --git a/crates/nu-command/src/commands/from_ods.rs b/crates/nu-command/src/commands/from_ods.rs index 2d2a346939..5ce3692c94 100644 --- a/crates/nu-command/src/commands/from_ods.rs +++ b/crates/nu-command/src/commands/from_ods.rs @@ -6,15 +6,15 @@ use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue}; use std::io::Cursor; -pub struct FromODS; +pub struct FromOds; #[derive(Deserialize)] -pub struct FromODSArgs { +pub struct FromOdsArgs { noheaders: bool, } #[async_trait] -impl WholeStreamCommand for FromODS { +impl WholeStreamCommand for FromOds { fn name(&self) -> &str { "from ods" } @@ -41,7 +41,7 @@ async fn from_ods(args: CommandArgs) -> Result { let span = tag.span; let ( - FromODSArgs { + FromOdsArgs { noheaders: _noheaders, }, input, @@ -93,13 +93,13 @@ async fn from_ods(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromODS; + use super::FromOds; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromODS {}) + test_examples(FromOds {}) } } diff --git a/crates/nu-command/src/commands/from_ssv.rs b/crates/nu-command/src/commands/from_ssv.rs index b634c3f936..23d75c0946 100644 --- a/crates/nu-command/src/commands/from_ssv.rs +++ b/crates/nu-command/src/commands/from_ssv.rs @@ -6,10 +6,10 @@ use nu_protocol::{ }; use nu_source::Tagged; -pub struct FromSSV; +pub struct FromSsv; #[derive(Deserialize)] -pub struct FromSSVArgs { +pub struct FromSsvArgs { noheaders: bool, #[serde(rename(deserialize = "aligned-columns"))] aligned_columns: bool, @@ -21,7 +21,7 @@ const STRING_REPRESENTATION: &str = "from ssv"; const DEFAULT_MINIMUM_SPACES: usize = 2; #[async_trait] -impl WholeStreamCommand for FromSSV { +impl WholeStreamCommand for FromSsv { fn name(&self) -> &str { STRING_REPRESENTATION } @@ -250,7 +250,7 @@ fn from_ssv_string_to_value( async fn from_ssv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( - FromSSVArgs { + FromSsvArgs { noheaders, aligned_columns, minimum_spaces, @@ -489,9 +489,9 @@ mod tests { #[test] fn examples_work_as_expected() -> Result<(), ShellError> { - use super::FromSSV; + use super::FromSsv; use crate::examples::test as test_examples; - test_examples(FromSSV {}) + test_examples(FromSsv {}) } } diff --git a/crates/nu-command/src/commands/from_toml.rs b/crates/nu-command/src/commands/from_toml.rs index 15b8061bef..2698f964cc 100644 --- a/crates/nu-command/src/commands/from_toml.rs +++ b/crates/nu-command/src/commands/from_toml.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Primitive, ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue, Value}; -pub struct FromTOML; +pub struct FromToml; #[async_trait] -impl WholeStreamCommand for FromTOML { +impl WholeStreamCommand for FromToml { fn name(&self) -> &str { "from toml" } @@ -92,13 +92,13 @@ pub async fn from_toml(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromTOML; + use super::FromToml; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromTOML {}) + test_examples(FromToml {}) } } diff --git a/crates/nu-command/src/commands/from_tsv.rs b/crates/nu-command/src/commands/from_tsv.rs index 78e27e419f..d7eaa01787 100644 --- a/crates/nu-command/src/commands/from_tsv.rs +++ b/crates/nu-command/src/commands/from_tsv.rs @@ -4,15 +4,15 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::Signature; -pub struct FromTSV; +pub struct FromTsv; #[derive(Deserialize)] -pub struct FromTSVArgs { +pub struct FromTsvArgs { noheaders: bool, } #[async_trait] -impl WholeStreamCommand for FromTSV { +impl WholeStreamCommand for FromTsv { fn name(&self) -> &str { "from tsv" } @@ -36,20 +36,20 @@ impl WholeStreamCommand for FromTSV { async fn from_tsv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); - let (FromTSVArgs { noheaders }, input) = args.process().await?; + let (FromTsvArgs { noheaders }, input) = args.process().await?; from_delimited_data(noheaders, '\t', "TSV", input, name).await } #[cfg(test)] mod tests { - use super::FromTSV; + use super::FromTsv; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromTSV {}) + test_examples(FromTsv {}) } } diff --git a/crates/nu-command/src/commands/from_url.rs b/crates/nu-command/src/commands/from_url.rs index 2275b55171..c8f92c99aa 100644 --- a/crates/nu-command/src/commands/from_url.rs +++ b/crates/nu-command/src/commands/from_url.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue}; -pub struct FromURL; +pub struct FromUrl; #[async_trait] -impl WholeStreamCommand for FromURL { +impl WholeStreamCommand for FromUrl { fn name(&self) -> &str { "from url" } @@ -55,13 +55,13 @@ async fn from_url(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromURL; + use super::FromUrl; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromURL {}) + test_examples(FromUrl {}) } } diff --git a/crates/nu-command/src/commands/from_xlsx.rs b/crates/nu-command/src/commands/from_xlsx.rs index cfd1395854..d3b5e824ce 100644 --- a/crates/nu-command/src/commands/from_xlsx.rs +++ b/crates/nu-command/src/commands/from_xlsx.rs @@ -6,15 +6,15 @@ use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue}; use std::io::Cursor; -pub struct FromXLSX; +pub struct FromXlsx; #[derive(Deserialize)] -pub struct FromXLSXArgs { +pub struct FromXlsxArgs { noheaders: bool, } #[async_trait] -impl WholeStreamCommand for FromXLSX { +impl WholeStreamCommand for FromXlsx { fn name(&self) -> &str { "from xlsx" } @@ -40,7 +40,7 @@ async fn from_xlsx(args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let span = tag.span; let ( - FromXLSXArgs { + FromXlsxArgs { noheaders: _noheaders, }, input, @@ -93,13 +93,13 @@ async fn from_xlsx(args: CommandArgs) -> Result { #[cfg(test)] mod tests { - use super::FromXLSX; + use super::FromXlsx; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromXLSX {}) + test_examples(FromXlsx {}) } } diff --git a/crates/nu-command/src/commands/from_xml.rs b/crates/nu-command/src/commands/from_xml.rs index c8ddeb2637..82fc975031 100644 --- a/crates/nu-command/src/commands/from_xml.rs +++ b/crates/nu-command/src/commands/from_xml.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Primitive, ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue, Value}; -pub struct FromXML; +pub struct FromXml; #[async_trait] -impl WholeStreamCommand for FromXML { +impl WholeStreamCommand for FromXml { fn name(&self) -> &str { "from xml" } @@ -298,9 +298,9 @@ mod tests { #[test] fn examples_work_as_expected() -> Result<(), ShellError> { - use super::FromXML; + use super::FromXml; use crate::examples::test as test_examples; - test_examples(FromXML {}) + test_examples(FromXml {}) } } diff --git a/crates/nu-command/src/commands/from_yaml.rs b/crates/nu-command/src/commands/from_yaml.rs index d631c8eca0..db9b3c3218 100644 --- a/crates/nu-command/src/commands/from_yaml.rs +++ b/crates/nu-command/src/commands/from_yaml.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Primitive, Signature, TaggedDictBuilder, UntaggedValue, Value}; -pub struct FromYAML; +pub struct FromYaml; #[async_trait] -impl WholeStreamCommand for FromYAML { +impl WholeStreamCommand for FromYaml { fn name(&self) -> &str { "from yaml" } @@ -24,10 +24,10 @@ impl WholeStreamCommand for FromYAML { } } -pub struct FromYML; +pub struct FromYml; #[async_trait] -impl WholeStreamCommand for FromYML { +impl WholeStreamCommand for FromYml { fn name(&self) -> &str { "from yml" } @@ -169,7 +169,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(FromYAML {}) + test_examples(FromYaml {}) } #[test] diff --git a/crates/nu-command/src/commands/to_csv.rs b/crates/nu-command/src/commands/to_csv.rs index 0dc6af94a5..6c02dd4ac8 100644 --- a/crates/nu-command/src/commands/to_csv.rs +++ b/crates/nu-command/src/commands/to_csv.rs @@ -4,16 +4,16 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Primitive, Signature, SyntaxShape, UntaggedValue, Value}; -pub struct ToCSV; +pub struct ToCsv; #[derive(Deserialize)] -pub struct ToCSVArgs { +pub struct ToCsvArgs { noheaders: bool, separator: Option, } #[async_trait] -impl WholeStreamCommand for ToCSV { +impl WholeStreamCommand for ToCsv { fn name(&self) -> &str { "to csv" } @@ -45,7 +45,7 @@ impl WholeStreamCommand for ToCSV { async fn to_csv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); let ( - ToCSVArgs { + ToCsvArgs { separator, noheaders, }, @@ -80,12 +80,12 @@ async fn to_csv(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToCSV; + use super::ToCsv; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToCSV {}) + test_examples(ToCsv {}) } } diff --git a/crates/nu-command/src/commands/to_html.rs b/crates/nu-command/src/commands/to_html.rs index dd8de05708..cb413fbe5a 100644 --- a/crates/nu-command/src/commands/to_html.rs +++ b/crates/nu-command/src/commands/to_html.rs @@ -79,10 +79,10 @@ impl Default for HtmlTheme { #[folder = "assets/"] struct Assets; -pub struct ToHTML; +pub struct ToHtml; #[derive(Deserialize)] -pub struct ToHTMLArgs { +pub struct ToHtmlArgs { html_color: bool, no_color: bool, dark: bool, @@ -92,7 +92,7 @@ pub struct ToHTMLArgs { } #[async_trait] -impl WholeStreamCommand for ToHTML { +impl WholeStreamCommand for ToHtml { fn name(&self) -> &str { "to html" } @@ -271,7 +271,7 @@ fn get_list_of_theme_names() -> Vec { async fn to_html(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let ( - ToHTMLArgs { + ToHtmlArgs { html_color, no_color, dark, @@ -758,6 +758,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToHTML {}) + test_examples(ToHtml {}) } } diff --git a/crates/nu-command/src/commands/to_json.rs b/crates/nu-command/src/commands/to_json.rs index ae5b227578..bf3e7faa0d 100644 --- a/crates/nu-command/src/commands/to_json.rs +++ b/crates/nu-command/src/commands/to_json.rs @@ -7,15 +7,15 @@ use nu_protocol::{ use serde::Serialize; use serde_json::json; -pub struct ToJSON; +pub struct ToJson; #[derive(Deserialize)] -pub struct ToJSONArgs { +pub struct ToJsonArgs { pretty: Option, } #[async_trait] -impl WholeStreamCommand for ToJSON { +impl WholeStreamCommand for ToJson { fn name(&self) -> &str { "to json" } @@ -160,7 +160,7 @@ fn json_list(input: &[Value]) -> Result, ShellError> { async fn to_json(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); - let (ToJSONArgs { pretty }, input) = args.process().await?; + let (ToJsonArgs { pretty }, input) = args.process().await?; let name_span = name_tag.span; let input: Vec = input.collect().await; @@ -256,12 +256,12 @@ async fn to_json(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToJSON; + use super::ToJson; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToJSON {}) + test_examples(ToJson {}) } } diff --git a/crates/nu-command/src/commands/to_toml.rs b/crates/nu-command/src/commands/to_toml.rs index 8d3092d0f6..90406cfc6c 100644 --- a/crates/nu-command/src/commands/to_toml.rs +++ b/crates/nu-command/src/commands/to_toml.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::{CoerceInto, ShellError}; use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; -pub struct ToTOML; +pub struct ToToml; #[async_trait] -impl WholeStreamCommand for ToTOML { +impl WholeStreamCommand for ToToml { fn name(&self) -> &str { "to toml" } @@ -195,7 +195,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToTOML {}) + test_examples(ToToml {}) } #[test] diff --git a/crates/nu-command/src/commands/to_tsv.rs b/crates/nu-command/src/commands/to_tsv.rs index a17e353ee5..41d359b7dd 100644 --- a/crates/nu-command/src/commands/to_tsv.rs +++ b/crates/nu-command/src/commands/to_tsv.rs @@ -4,15 +4,15 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::Signature; -pub struct ToTSV; +pub struct ToTsv; #[derive(Deserialize)] -pub struct ToTSVArgs { +pub struct ToTsvArgs { noheaders: bool, } #[async_trait] -impl WholeStreamCommand for ToTSV { +impl WholeStreamCommand for ToTsv { fn name(&self) -> &str { "to tsv" } @@ -36,7 +36,7 @@ impl WholeStreamCommand for ToTSV { async fn to_tsv(args: CommandArgs) -> Result { let name = args.call_info.name_tag.clone(); - let (ToTSVArgs { noheaders }, input) = args.process().await?; + let (ToTsvArgs { noheaders }, input) = args.process().await?; to_delimited_data(noheaders, '\t', "TSV", input, name).await } @@ -44,12 +44,12 @@ async fn to_tsv(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToTSV; + use super::ToTsv; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToTSV {}) + test_examples(ToTsv {}) } } diff --git a/crates/nu-command/src/commands/to_url.rs b/crates/nu-command/src/commands/to_url.rs index 9ff917b797..0f21cf1a26 100644 --- a/crates/nu-command/src/commands/to_url.rs +++ b/crates/nu-command/src/commands/to_url.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{ReturnSuccess, Signature, UntaggedValue, Value}; -pub struct ToURL; +pub struct ToUrl; #[async_trait] -impl WholeStreamCommand for ToURL { +impl WholeStreamCommand for ToUrl { fn name(&self) -> &str { "to url" } @@ -76,12 +76,12 @@ async fn to_url(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToURL; + use super::ToUrl; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToURL {}) + test_examples(ToUrl {}) } } diff --git a/crates/nu-command/src/commands/to_xml.rs b/crates/nu-command/src/commands/to_xml.rs index 6514bff265..c97fa2442c 100644 --- a/crates/nu-command/src/commands/to_xml.rs +++ b/crates/nu-command/src/commands/to_xml.rs @@ -8,15 +8,15 @@ use std::collections::HashSet; use std::io::Cursor; use std::io::Write; -pub struct ToXML; +pub struct ToXml; #[derive(Deserialize)] -pub struct ToXMLArgs { +pub struct ToXmlArgs { pretty: Option, } #[async_trait] -impl WholeStreamCommand for ToXML { +impl WholeStreamCommand for ToXml { fn name(&self) -> &str { "to xml" } @@ -135,7 +135,7 @@ pub fn write_xml_events( async fn to_xml(args: CommandArgs) -> Result { let name_tag = args.call_info.name_tag.clone(); let name_span = name_tag.span; - let (ToXMLArgs { pretty }, input) = args.process().await?; + let (ToXmlArgs { pretty }, input) = args.process().await?; let input: Vec = input.collect().await; let to_process_input = match input.len() { @@ -189,12 +189,12 @@ async fn to_xml(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToXML; + use super::ToXml; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToXML {}) + test_examples(ToXml {}) } } diff --git a/crates/nu-command/src/commands/to_yaml.rs b/crates/nu-command/src/commands/to_yaml.rs index cdfaabd3b5..caf9f275f3 100644 --- a/crates/nu-command/src/commands/to_yaml.rs +++ b/crates/nu-command/src/commands/to_yaml.rs @@ -3,10 +3,10 @@ use nu_engine::WholeStreamCommand; use nu_errors::{CoerceInto, ShellError}; use nu_protocol::{Primitive, ReturnSuccess, Signature, UnspannedPathMember, UntaggedValue, Value}; -pub struct ToYAML; +pub struct ToYaml; #[async_trait] -impl WholeStreamCommand for ToYAML { +impl WholeStreamCommand for ToYaml { fn name(&self) -> &str { "to yaml" } @@ -164,12 +164,12 @@ async fn to_yaml(args: CommandArgs) -> Result { #[cfg(test)] mod tests { use super::ShellError; - use super::ToYAML; + use super::ToYaml; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(ToYAML {}) + test_examples(ToYaml {}) } } diff --git a/crates/nu-command/tests/commands/get.rs b/crates/nu-command/tests/commands/get.rs index f2853afa2e..667acf94dd 100644 --- a/crates/nu-command/tests/commands/get.rs +++ b/crates/nu-command/tests/commands/get.rs @@ -151,24 +151,12 @@ fn errors_fetching_by_column_not_present() { "# )); - assert!( - actual.err.contains("Unknown column"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("There isn't a column named 'taco'"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("Perhaps you meant 'taconushell'?"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual - .err - .contains("Columns available: pizzanushell, taconushell"), - format!("actual: {:?}", actual.err) - ); + assert!(actual.err.contains("Unknown column"),); + assert!(actual.err.contains("There isn't a column named 'taco'"),); + assert!(actual.err.contains("Perhaps you meant 'taconushell'?"),); + assert!(actual + .err + .contains("Columns available: pizzanushell, taconushell"),); }) } @@ -191,20 +179,11 @@ fn errors_fetching_by_column_using_a_number() { "# )); - assert!( - actual.err.contains("No rows available"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("A row at '0' can't be indexed."), - format!("actual: {:?}", actual.err) - ); - assert!( - actual - .err - .contains("Appears to contain columns. Columns available: 0"), - format!("actual: {:?}", actual.err) - ) + assert!(actual.err.contains("No rows available"),); + assert!(actual.err.contains("A row at '0' can't be indexed."),); + assert!(actual + .err + .contains("Appears to contain columns. Columns available: 0"),) }) } #[test] @@ -226,18 +205,9 @@ fn errors_fetching_by_index_out_of_bounds() { "# )); - assert!( - actual.err.contains("Row not found"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("There isn't a row indexed at 3"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("The table only has 3 rows (0 to 2)"), - format!("actual: {:?}", actual.err) - ) + assert!(actual.err.contains("Row not found"),); + assert!(actual.err.contains("There isn't a row indexed at 3"),); + assert!(actual.err.contains("The table only has 3 rows (0 to 2)"),) }) } diff --git a/crates/nu-command/tests/commands/rename.rs b/crates/nu-command/tests/commands/rename.rs index fc48799466..f4ea04b66a 100644 --- a/crates/nu-command/tests/commands/rename.rs +++ b/crates/nu-command/tests/commands/rename.rs @@ -83,13 +83,7 @@ fn errors_if_no_columns_present() { "# )); - assert!( - actual.err.contains("no column names available"), - format!("actual: {:?}", actual.err) - ); - assert!( - actual.err.contains("can't rename"), - format!("actual: {:?}", actual.err) - ); + assert!(actual.err.contains("no column names available")); + assert!(actual.err.contains("can't rename")); }) } diff --git a/crates/nu-data/src/primitive.rs b/crates/nu-data/src/primitive.rs index 878eb20e12..9912f3f11b 100644 --- a/crates/nu-data/src/primitive.rs +++ b/crates/nu-data/src/primitive.rs @@ -146,7 +146,7 @@ pub fn get_color_config() -> HashMap { hm.insert("index_color".to_string(), Color::Green.bold()); hm.insert( "leading_trailing_space_bg".to_string(), - Style::default().on(Color::RGB(128, 128, 128)), + Style::default().on(Color::Rgb(128, 128, 128)), ); // populate hashmap from config values diff --git a/crates/nu-engine/src/shell/palette.rs b/crates/nu-engine/src/shell/palette.rs index 04c0fb9fff..9437b7688c 100644 --- a/crates/nu-engine/src/shell/palette.rs +++ b/crates/nu-engine/src/shell/palette.rs @@ -241,7 +241,7 @@ impl ThemeColor { let r = ThemeColor::xtoi(&mut bytes)?; let g = ThemeColor::xtoi(&mut bytes)?; let b = ThemeColor::xtoi(&mut bytes)?; - Ok(ThemeColor(Color::RGB(r, g, b))) + Ok(ThemeColor(Color::Rgb(r, g, b))) } fn xtoi(b: &mut Bytes) -> Result @@ -329,7 +329,7 @@ mod tests { assert_eq!( styled[0], Spanned { - item: Color::RGB(163, 89, 204).bold(), + item: Color::Rgb(163, 89, 204).bold(), span: Span::new(4, 9), }, ); diff --git a/crates/nu-json/src/de.rs b/crates/nu-json/src/de.rs index 12bcf2db2d..a70ffecc7f 100644 --- a/crates/nu-json/src/de.rs +++ b/crates/nu-json/src/de.rs @@ -105,7 +105,7 @@ where return visitor.visit_str(s); } else if ch <= b' ' { if ch == 0 { - return Err(self.rdr.error(ErrorCode::EOFWhileParsingObject)); + return Err(self.rdr.error(ErrorCode::EofWhileParsingObject)); } else if space.is_none() { space = Some(self.str_buf.len()); } @@ -124,7 +124,7 @@ where self.rdr.parse_whitespace()?; if self.rdr.eof()? { - return Err(self.rdr.error(ErrorCode::EOFWhileParsingValue)); + return Err(self.rdr.error(ErrorCode::EofWhileParsingValue)); } match self.state { @@ -162,7 +162,7 @@ where match self.rdr.next_char()? { Some(b']') => Ok(ret), Some(_) => Err(self.rdr.error(ErrorCode::TrailingCharacters)), - None => Err(self.rdr.error(ErrorCode::EOFWhileParsingList)), + None => Err(self.rdr.error(ErrorCode::EofWhileParsingList)), } } b'{' => { @@ -193,7 +193,7 @@ where if root { Ok(ret) } else { - Err(self.rdr.error(ErrorCode::EOFWhileParsingObject)) + Err(self.rdr.error(ErrorCode::EofWhileParsingObject)) } } } @@ -374,7 +374,7 @@ where // When parsing multiline string values, we must look for ' characters. loop { if self.rdr.eof()? { - return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + return Err(self.rdr.error(ErrorCode::EofWhileParsingString)); } // todo error("Bad multiline string"); let ch = self.rdr.next_char_or_null()?; @@ -413,7 +413,7 @@ where let ch = match self.rdr.next_char()? { Some(ch) => ch, None => { - return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + return Err(self.rdr.error(ErrorCode::EofWhileParsingString)); } }; @@ -425,7 +425,7 @@ where let ch = match self.rdr.next_char()? { Some(ch) => ch, None => { - return Err(self.rdr.error(ErrorCode::EOFWhileParsingString)); + return Err(self.rdr.error(ErrorCode::EofWhileParsingString)); } }; @@ -509,7 +509,7 @@ where match self.rdr.next_char()? { Some(b':') => Ok(()), Some(_) => Err(self.rdr.error(ErrorCode::ExpectedColon)), - None => Err(self.rdr.error(ErrorCode::EOFWhileParsingObject)), + None => Err(self.rdr.error(ErrorCode::EofWhileParsingObject)), } } } @@ -592,7 +592,7 @@ where } Some(_) => {} None => { - return Err(self.de.rdr.error(ErrorCode::EOFWhileParsingList)); + return Err(self.de.rdr.error(ErrorCode::EofWhileParsingList)); } } @@ -652,7 +652,7 @@ where if self.root { return Ok(None); } else { - return Err(self.de.rdr.error(ErrorCode::EOFWhileParsingObject)); + return Err(self.de.rdr.error(ErrorCode::EofWhileParsingObject)); } } } @@ -666,7 +666,7 @@ where }; Ok(Some(seed.deserialize(&mut *self.de)?)) } - None => Err(self.de.rdr.error(ErrorCode::EOFWhileParsingValue)), + None => Err(self.de.rdr.error(ErrorCode::EofWhileParsingValue)), } } @@ -676,7 +676,7 @@ where { self.de.parse_object_colon()?; - Ok(seed.deserialize(&mut *self.de)?) + seed.deserialize(&mut *self.de) } } diff --git a/crates/nu-json/src/error.rs b/crates/nu-json/src/error.rs index f42812980a..7c9ebafa34 100644 --- a/crates/nu-json/src/error.rs +++ b/crates/nu-json/src/error.rs @@ -19,16 +19,16 @@ pub enum ErrorCode { Custom(String), /// EOF while parsing a list. - EOFWhileParsingList, + EofWhileParsingList, /// EOF while parsing an object. - EOFWhileParsingObject, + EofWhileParsingObject, /// EOF while parsing a string. - EOFWhileParsingString, + EofWhileParsingString, /// EOF while parsing a JSON value. - EOFWhileParsingValue, + EofWhileParsingValue, /// Expected this character to be a `':'`. ExpectedColon, @@ -76,10 +76,10 @@ impl fmt::Debug for ErrorCode { match *self { ErrorCode::Custom(ref msg) => write!(f, "{}", msg), - ErrorCode::EOFWhileParsingList => "EOF while parsing a list".fmt(f), - ErrorCode::EOFWhileParsingObject => "EOF while parsing an object".fmt(f), - ErrorCode::EOFWhileParsingString => "EOF while parsing a string".fmt(f), - ErrorCode::EOFWhileParsingValue => "EOF while parsing a value".fmt(f), + ErrorCode::EofWhileParsingList => "EOF while parsing a list".fmt(f), + ErrorCode::EofWhileParsingObject => "EOF while parsing an object".fmt(f), + ErrorCode::EofWhileParsingString => "EOF while parsing a string".fmt(f), + ErrorCode::EofWhileParsingValue => "EOF while parsing a value".fmt(f), ErrorCode::ExpectedColon => "expected `:`".fmt(f), ErrorCode::ExpectedListCommaOrEnd => "expected `,` or `]`".fmt(f), ErrorCode::ExpectedObjectCommaOrEnd => "expected `,` or `}`".fmt(f), diff --git a/crates/nu-json/src/value.rs b/crates/nu-json/src/value.rs index 850abdfbc6..628f07db42 100644 --- a/crates/nu-json/src/value.rs +++ b/crates/nu-json/src/value.rs @@ -1092,7 +1092,7 @@ impl<'de, 'a> de::MapAccess<'de> for MapDeserializer { V: de::DeserializeSeed<'de>, { let value = self.value.take().expect("value is missing"); - Ok(seed.deserialize(value)?) + seed.deserialize(value) } fn size_hint(&self) -> Option { @@ -1150,18 +1150,18 @@ mod test { let v: Value = from_str("{\"a\":1.1}").unwrap(); let vo = v.as_object().unwrap(); - assert_eq!(vo["a"].as_f64().unwrap(), 1.1); + assert!(vo["a"].as_f64().unwrap() - 1.1 < std::f64::EPSILON); let v: Value = from_str("{\"a\":-1.1}").unwrap(); let vo = v.as_object().unwrap(); - assert_eq!(vo["a"].as_f64().unwrap(), -1.1); + assert!(vo["a"].as_f64().unwrap() + 1.1 > -(std::f64::EPSILON)); let v: Value = from_str("{\"a\":1e6}").unwrap(); let vo = v.as_object().unwrap(); - assert_eq!(vo["a"].as_f64().unwrap(), 1e6); + assert!(vo["a"].as_f64().unwrap() - 1e6 < std::f64::EPSILON); let v: Value = from_str("{\"a\":-1e6}").unwrap(); let vo = v.as_object().unwrap(); - assert_eq!(vo["a"].as_f64().unwrap(), -1e6); + assert!(vo["a"].as_f64().unwrap() + 1e6 > -(std::f64::EPSILON)); } } diff --git a/crates/nu-json/tests/main.rs b/crates/nu-json/tests/main.rs index c06d83e0cf..b7961bc397 100644 --- a/crates/nu-json/tests/main.rs +++ b/crates/nu-json/tests/main.rs @@ -115,7 +115,7 @@ fn fix_pass1(json: String) -> String { fn test_hjson() { let mut done: Vec = Vec::new(); - println!(""); + println!(); run_test!(charset, done, std_fix); run_test!(comments, done, std_fix); run_test!(empty, done, std_fix); @@ -197,18 +197,17 @@ fn test_hjson() { let all = paths .map(|item| String::from(item.unwrap().path().file_stem().unwrap().to_str().unwrap())) - .filter(|x| x.contains("_test")) - .collect::>(); + .filter(|x| x.contains("_test")); let missing = all .into_iter() .filter(|x| done.iter().find(|y| &x == y) == None) .collect::>(); - if missing.len() > 0 { + if !missing.is_empty() { for item in missing { println!("missing: {}", item); } - assert!(false); + panic!(); } } diff --git a/crates/nu-parser/src/lex/lexer.rs b/crates/nu-parser/src/lex/lexer.rs index 2ff8a2c27d..5ee52e04ea 100644 --- a/crates/nu-parser/src/lex/lexer.rs +++ b/crates/nu-parser/src/lex/lexer.rs @@ -360,12 +360,12 @@ pub fn parse_block(tokens: Vec) -> (LiteBlock, Option) { // - semicolon while let Some(token) = tokens.next() { match &token.contents { - TokenContents::EOL => { + TokenContents::Eol => { // If we encounter two newline characters in a row, use a special eoleol event, // which allows the parser to discard comments that shouldn't be treated as // documentation for the following item. if let Some(Token { - contents: TokenContents::EOL, + contents: TokenContents::Eol, .. }) = tokens.peek() { @@ -480,7 +480,7 @@ pub fn lex(input: &str, span_offset: usize) -> (Vec, Option) let idx = *idx; let _ = char_indices.next(); output.push(Token::new( - TokenContents::EOL, + TokenContents::Eol, Span::new(span_offset + idx, span_offset + idx + 1), )); } else if *c == '#' { diff --git a/crates/nu-parser/src/lex/tokens.rs b/crates/nu-parser/src/lex/tokens.rs index baa23a3eae..7fdb35dd6f 100644 --- a/crates/nu-parser/src/lex/tokens.rs +++ b/crates/nu-parser/src/lex/tokens.rs @@ -19,7 +19,7 @@ pub enum TokenContents { Comment(LiteComment), Pipe, Semicolon, - EOL, + Eol, } impl fmt::Display for TokenContents { @@ -29,7 +29,7 @@ impl fmt::Display for TokenContents { TokenContents::Comment(comm) => write!(f, "{}", comm), TokenContents::Pipe => write!(f, "|"), TokenContents::Semicolon => write!(f, ";"), - TokenContents::EOL => write!(f, "\\n"), + TokenContents::Eol => write!(f, "\\n"), } } } diff --git a/crates/nu-plugin/src/test_helpers.rs b/crates/nu-plugin/src/test_helpers.rs index bf3b2bf480..1345656deb 100644 --- a/crates/nu-plugin/src/test_helpers.rs +++ b/crates/nu-plugin/src/test_helpers.rs @@ -71,10 +71,7 @@ impl<'a, T: Plugin> PluginTest<'a, T> { for flag in flags { assert!( flags_configured.iter().any(|f| *f == flag), - format!( - "The flag you passed ({}) is not configured in the plugin.", - flag - ) + "The flag you passed is not configured in the plugin.", ); } } @@ -143,7 +140,7 @@ pub fn expect_return_value_at( for (idx, item) in return_values.iter().enumerate() { let item = match item { Ok(return_value) => return_value, - Err(reason) => panic!(format!("{}", reason)), + Err(_) => panic!("Unexpected value"), }; if idx == at { @@ -155,9 +152,5 @@ pub fn expect_return_value_at( } } - panic!(format!( - "Couldn't get return value from stream at {}. (There are {} items)", - at, - return_values.len() - 1 - )) + panic!("Couldn't get return value from stream.") } diff --git a/crates/nu-table/src/main.rs b/crates/nu-table/src/main.rs index 268e1f29f7..36fe20528c 100644 --- a/crates/nu-table/src/main.rs +++ b/crates/nu-table/src/main.rs @@ -31,37 +31,39 @@ fn main() { } fn make_table_data() -> (Vec<&'static str>, Vec<&'static str>) { - let mut table_headers = vec![]; - table_headers.push("category"); - table_headers.push("description"); - table_headers.push("emoji"); - table_headers.push("ios_version"); - table_headers.push("unicode_version"); - table_headers.push("aliases"); - table_headers.push("tags"); - table_headers.push("category2"); - table_headers.push("description2"); - table_headers.push("emoji2"); - table_headers.push("ios_version2"); - table_headers.push("unicode_version2"); - table_headers.push("aliases2"); - table_headers.push("tags2"); + let table_headers = vec![ + "category", + "description", + "emoji", + "ios_version", + "unicode_version", + "aliases", + "tags", + "category2", + "description2", + "emoji2", + "ios_version2", + "unicode_version2", + "aliases2", + "tags2", + ]; - let mut row_data = vec![]; - row_data.push("Smileys & Emotion"); - row_data.push("grinning face"); - row_data.push("😀"); - row_data.push("6"); - row_data.push("6.1"); - row_data.push("grinning"); - row_data.push("smile"); - row_data.push("Smileys & Emotion"); - row_data.push("grinning face"); - row_data.push("😀"); - row_data.push("6"); - row_data.push("6.1"); - row_data.push("grinning"); - row_data.push("smile"); + let row_data = vec![ + "Smileys & Emotion", + "grinning face", + "😀", + "6", + "6.1", + "grinning", + "smile", + "Smileys & Emotion", + "grinning face", + "😀", + "6", + "6.1", + "grinning", + "smile", + ]; (table_headers, row_data) } diff --git a/crates/nu-test-support/src/fs.rs b/crates/nu-test-support/src/fs.rs index 74ba94b9ad..170f971da5 100644 --- a/crates/nu-test-support/src/fs.rs +++ b/crates/nu-test-support/src/fs.rs @@ -196,8 +196,8 @@ pub fn delete_file_at(full_path: impl AsRef) { pub fn create_file_at(full_path: impl AsRef) -> Result<(), std::io::Error> { let full_path = full_path.as_ref(); - if let Some(parent) = full_path.parent() { - panic!(format!("{:?} exists", parent.display())); + if full_path.parent().is_some() { + panic!("path exists"); } std::fs::write(full_path, b"fake data") diff --git a/crates/nu_plugin_binaryview/src/binaryview.rs b/crates/nu_plugin_binaryview/src/binaryview.rs index 08bf086d3b..c8eee06d0e 100644 --- a/crates/nu_plugin_binaryview/src/binaryview.rs +++ b/crates/nu_plugin_binaryview/src/binaryview.rs @@ -63,7 +63,7 @@ impl RenderContext { Some(c) => { print!( "{}", - nu_ansi_term::Color::RGB(c.0, c.1, c.2) + nu_ansi_term::Color::Rgb(c.0, c.1, c.2) .paint((0..prev_count).map(|_| "█").collect::()) ); prev_color = Some(*pixel); @@ -80,7 +80,7 @@ impl RenderContext { if let Some(color) = prev_color { print!( "{}", - nu_ansi_term::Color::RGB(color.0, color.1, color.2) + nu_ansi_term::Color::Rgb(color.0, color.1, color.2) .paint((0..prev_count).map(|_| "█").collect::()) ); } @@ -108,8 +108,8 @@ impl RenderContext { (Some(c), Some(d)) => { print!( "{}", - nu_ansi_term::Color::RGB(c.0, c.1, c.2) - .on(nu_ansi_term::Color::RGB(d.0, d.1, d.2,)) + nu_ansi_term::Color::Rgb(c.0, c.1, c.2) + .on(nu_ansi_term::Color::Rgb(d.0, d.1, d.2,)) .paint((0..prev_count).map(|_| "▀").collect::()) ); prev_fg = Some(top_pixel); @@ -131,8 +131,8 @@ impl RenderContext { if let (Some(c), Some(d)) = (prev_fg, prev_bg) { print!( "{}", - nu_ansi_term::Color::RGB(c.0, c.1, c.2) - .on(nu_ansi_term::Color::RGB(d.0, d.1, d.2,)) + nu_ansi_term::Color::Rgb(c.0, c.1, c.2) + .on(nu_ansi_term::Color::Rgb(d.0, d.1, d.2,)) .paint((0..prev_count).map(|_| "▀").collect::()) ); } diff --git a/crates/nu_plugin_from_bson/src/from_bson.rs b/crates/nu_plugin_from_bson/src/from_bson.rs index a1a1f8fcb4..cf146b9f61 100644 --- a/crates/nu_plugin_from_bson/src/from_bson.rs +++ b/crates/nu_plugin_from_bson/src/from_bson.rs @@ -6,14 +6,14 @@ use nu_source::{SpannedItem, Tag}; use std::str::FromStr; #[derive(Default)] -pub struct FromBSON { +pub struct FromBson { pub state: Vec, pub name_tag: Tag, } -impl FromBSON { - pub fn new() -> FromBSON { - FromBSON { +impl FromBson { + pub fn new() -> FromBson { + FromBson { state: vec![], name_tag: Tag::unknown(), } diff --git a/crates/nu_plugin_from_bson/src/lib.rs b/crates/nu_plugin_from_bson/src/lib.rs index 2670658005..c037ee0289 100644 --- a/crates/nu_plugin_from_bson/src/lib.rs +++ b/crates/nu_plugin_from_bson/src/lib.rs @@ -1,4 +1,4 @@ mod from_bson; mod nu; -pub use from_bson::FromBSON; +pub use from_bson::FromBson; diff --git a/crates/nu_plugin_from_bson/src/main.rs b/crates/nu_plugin_from_bson/src/main.rs index c3db0e7341..bec813d017 100644 --- a/crates/nu_plugin_from_bson/src/main.rs +++ b/crates/nu_plugin_from_bson/src/main.rs @@ -1,6 +1,6 @@ use nu_plugin::serve_plugin; -use nu_plugin_from_bson::FromBSON; +use nu_plugin_from_bson::FromBson; fn main() { - serve_plugin(&mut FromBSON::new()) + serve_plugin(&mut FromBson::new()) } diff --git a/crates/nu_plugin_from_bson/src/nu/mod.rs b/crates/nu_plugin_from_bson/src/nu/mod.rs index ca0a26112b..0a6584d01f 100644 --- a/crates/nu_plugin_from_bson/src/nu/mod.rs +++ b/crates/nu_plugin_from_bson/src/nu/mod.rs @@ -1,13 +1,13 @@ #[cfg(test)] mod tests; -use crate::FromBSON; +use crate::FromBson; use nu_errors::ShellError; use nu_plugin::Plugin; use nu_protocol::{CallInfo, Primitive, ReturnValue, Signature, UntaggedValue, Value}; use nu_source::Tag; -impl Plugin for FromBSON { +impl Plugin for FromBson { fn config(&mut self) -> Result { Ok(Signature::build("from bson") .desc("Convert from .bson binary into table") diff --git a/crates/nu_plugin_inc/src/lib.rs b/crates/nu_plugin_inc/src/lib.rs index 42f06fdefe..9167c0be44 100644 --- a/crates/nu_plugin_inc/src/lib.rs +++ b/crates/nu_plugin_inc/src/lib.rs @@ -14,24 +14,21 @@ mod tests { pub fn expect_action(&self, action: Action) { match &self.action { Some(set) if set == &action => {} - Some(other) => panic!(format!("\nExpected {:#?}\n\ngot {:#?}", action, other)), - None => panic!(format!("\nAction {:#?} not found.", 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(reason) => panic!(format!( - "\nExpected {:#?} to be a ColumnPath, \n\ngot {:#?}", - field, reason - )), + Err(_) => panic!("\nExpected a ColumnPath",), }; match &self.field { Some(column_path) if column_path == &field => {} - Some(other) => panic!(format!("\nExpected {:#?} \n\ngot {:#?}", field, other)), - None => panic!(format!("\nField {:#?} not found.", field)), + Some(_) => panic!("\nUnexpected field."), + None => panic!("\nField not found."), } } } diff --git a/crates/nu_plugin_to_bson/src/lib.rs b/crates/nu_plugin_to_bson/src/lib.rs index b823777b51..9193d10c5e 100644 --- a/crates/nu_plugin_to_bson/src/lib.rs +++ b/crates/nu_plugin_to_bson/src/lib.rs @@ -1,4 +1,4 @@ mod nu; mod to_bson; -pub use to_bson::ToBSON; +pub use to_bson::ToBson; diff --git a/crates/nu_plugin_to_bson/src/main.rs b/crates/nu_plugin_to_bson/src/main.rs index 2170b73e46..47d3f0468c 100644 --- a/crates/nu_plugin_to_bson/src/main.rs +++ b/crates/nu_plugin_to_bson/src/main.rs @@ -1,6 +1,6 @@ use nu_plugin::serve_plugin; -use nu_plugin_to_bson::ToBSON; +use nu_plugin_to_bson::ToBson; fn main() { - serve_plugin(&mut ToBSON::new()) + serve_plugin(&mut ToBson::new()) } diff --git a/crates/nu_plugin_to_bson/src/nu/mod.rs b/crates/nu_plugin_to_bson/src/nu/mod.rs index d732183f15..515fafe212 100644 --- a/crates/nu_plugin_to_bson/src/nu/mod.rs +++ b/crates/nu_plugin_to_bson/src/nu/mod.rs @@ -1,13 +1,13 @@ #[cfg(test)] mod tests; -use crate::ToBSON; +use crate::ToBson; use nu_errors::ShellError; use nu_plugin::Plugin; use nu_protocol::{ReturnValue, Signature, Value}; use nu_source::Tag; -impl Plugin for ToBSON { +impl Plugin for ToBson { fn config(&mut self) -> Result { Ok(Signature::build("to bson") .desc("Convert table into .bson binary") diff --git a/crates/nu_plugin_to_bson/src/to_bson.rs b/crates/nu_plugin_to_bson/src/to_bson.rs index 5edf850cc6..ddaee3928f 100644 --- a/crates/nu_plugin_to_bson/src/to_bson.rs +++ b/crates/nu_plugin_to_bson/src/to_bson.rs @@ -9,13 +9,13 @@ use num_traits::ToPrimitive; use std::convert::TryInto; #[derive(Default)] -pub struct ToBSON { +pub struct ToBson { pub state: Vec, } -impl ToBSON { - pub fn new() -> ToBSON { - ToBSON { state: vec![] } +impl ToBson { + pub fn new() -> ToBson { + ToBson { state: vec![] } } } diff --git a/src/plugins/nu_plugin_extra_from_bson.rs b/src/plugins/nu_plugin_extra_from_bson.rs index 8c5868fa8d..ffc24fca4c 100644 --- a/src/plugins/nu_plugin_extra_from_bson.rs +++ b/src/plugins/nu_plugin_extra_from_bson.rs @@ -1,6 +1,6 @@ use nu_plugin::serve_plugin; -use nu_plugin_from_bson::FromBSON; +use nu_plugin_from_bson::FromBson; fn main() { - serve_plugin(&mut FromBSON::new()); + serve_plugin(&mut FromBson::new()); } diff --git a/src/plugins/nu_plugin_extra_to_bson.rs b/src/plugins/nu_plugin_extra_to_bson.rs index 2170b73e46..47d3f0468c 100644 --- a/src/plugins/nu_plugin_extra_to_bson.rs +++ b/src/plugins/nu_plugin_extra_to_bson.rs @@ -1,6 +1,6 @@ use nu_plugin::serve_plugin; -use nu_plugin_to_bson::ToBSON; +use nu_plugin_to_bson::ToBson; fn main() { - serve_plugin(&mut ToBSON::new()) + serve_plugin(&mut ToBson::new()) } diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index 54a6b48d15..60173241fc 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -259,10 +259,7 @@ mod tilde_expansion { "# ); - assert!( - !actual.out.contains('~'), - format!("'{}' should not contain ~", actual.out) - ); + assert!(!actual.out.contains('~')); } #[test] diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs index d34eebfe3f..28648af881 100644 --- a/tests/shell/pipeline/commands/internal.rs +++ b/tests/shell/pipeline/commands/internal.rs @@ -716,49 +716,25 @@ mod parse { fn errors_if_flag_passed_is_not_exact() { let actual = nu!(cwd: ".", "debug -ra"); - assert!( - actual.err.contains("unexpected flag"), - format!( - "error message '{}' should contain 'unexpected flag'", - actual.err - ) - ); + assert!(actual.err.contains("unexpected flag"),); let actual = nu!(cwd: ".", "debug --rawx"); - assert!( - actual.err.contains("unexpected flag"), - format!( - "error message '{}' should contain 'unexpected flag'", - actual.err - ) - ); + assert!(actual.err.contains("unexpected flag"),); } #[test] fn errors_if_flag_is_not_supported() { let actual = nu!(cwd: ".", "debug --ferris"); - assert!( - actual.err.contains("unexpected flag"), - format!( - "error message '{}' should contain 'unexpected flag'", - actual.err - ) - ); + assert!(actual.err.contains("unexpected flag"),); } #[test] fn errors_if_passed_an_unexpected_argument() { let actual = nu!(cwd: ".", "debug ferris"); - assert!( - actual.err.contains("unexpected argument"), - format!( - "error message '{}' should contain 'unexpected argument'", - actual.err - ) - ); + assert!(actual.err.contains("unexpected argument"),); } } @@ -775,10 +751,7 @@ mod tilde_expansion { "# ); - assert!( - !actual.out.contains('~'), - format!("'{}' should not contain ~", actual.out) - ); + assert!(!actual.out.contains('~'),); } #[test]