mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 08:59:12 +01:00
Fix latest clippy warnings (#3049)
This commit is contained in:
parent
041086d22a
commit
5481db4079
@ -151,6 +151,7 @@ xpath = ["nu_plugin_xpath"]
|
||||
codegen-units = 1 #Reduce parallel codegen units
|
||||
lto = true #Link Time Optimization
|
||||
opt-level = 'z' #Optimize for size
|
||||
debug = true
|
||||
|
||||
# Core plugins that ship with `cargo install nu` by default
|
||||
# Currently, Cargo limits us to installing only one binary
|
||||
|
@ -48,16 +48,14 @@ pub fn search_paths() -> Vec<std::path::PathBuf> {
|
||||
}
|
||||
|
||||
if let Ok(config) = nu_data::config::config(Tag::unknown()) {
|
||||
if let Some(plugin_dirs) = config.get("plugin_dirs") {
|
||||
if let Value {
|
||||
value: UntaggedValue::Table(pipelines),
|
||||
..
|
||||
} = plugin_dirs
|
||||
{
|
||||
for pipeline in pipelines {
|
||||
if let Ok(plugin_dir) = pipeline.as_string() {
|
||||
search_paths.push(PathBuf::from(plugin_dir));
|
||||
}
|
||||
if let Some(Value {
|
||||
value: UntaggedValue::Table(pipelines),
|
||||
..
|
||||
}) = config.get("plugin_dirs")
|
||||
{
|
||||
for pipeline in pipelines {
|
||||
if let Ok(plugin_dir) = pipeline.as_string() {
|
||||
search_paths.push(PathBuf::from(plugin_dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl DirectorySpecificEnvironment {
|
||||
}
|
||||
}
|
||||
|
||||
fn toml_if_trusted(&mut self, nu_env_file: &PathBuf) -> Result<NuEnvDoc, ShellError> {
|
||||
fn toml_if_trusted(&mut self, nu_env_file: &Path) -> Result<NuEnvDoc, ShellError> {
|
||||
let content = std::fs::read(&nu_env_file)?;
|
||||
|
||||
if autoenv::file_is_trusted(&nu_env_file, &content)? {
|
||||
@ -161,7 +161,7 @@ impl DirectorySpecificEnvironment {
|
||||
pub fn maybe_add_key(
|
||||
&mut self,
|
||||
seen_vars: &mut IndexSet<EnvKey>,
|
||||
dir: &PathBuf,
|
||||
dir: &Path,
|
||||
key: &str,
|
||||
val: &str,
|
||||
) {
|
||||
@ -169,7 +169,7 @@ impl DirectorySpecificEnvironment {
|
||||
if !seen_vars.contains(key) {
|
||||
seen_vars.insert(key.to_string());
|
||||
self.added_vars
|
||||
.entry(dir.clone())
|
||||
.entry(PathBuf::from(dir))
|
||||
.or_insert(IndexMap::new())
|
||||
.insert(key.to_string(), var_os(key));
|
||||
|
||||
|
@ -58,6 +58,7 @@ pub(crate) use nu_value_ext::ValueExt;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use std::sync::atomic::Ordering;
|
||||
|
||||
#[allow(clippy::clippy::wrong_self_convention)]
|
||||
pub trait FromInputStream {
|
||||
fn from_input_stream(self) -> OutputStream;
|
||||
}
|
||||
@ -73,6 +74,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::clippy::wrong_self_convention)]
|
||||
pub trait ToOutputStream {
|
||||
fn to_output_stream(self) -> OutputStream;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ fn get_result_shape_of(
|
||||
l_shape: SyntaxShape,
|
||||
op_expr: &SpannedExpression,
|
||||
r_shape: SyntaxShape,
|
||||
) -> Result<SyntaxShape, ShellError> {
|
||||
) -> SyntaxShape {
|
||||
let op = match op_expr.expr {
|
||||
Expression::Literal(Literal::Operator(op)) => op,
|
||||
_ => unreachable!("Passing anything but the op expr is invalid"),
|
||||
@ -220,7 +220,7 @@ fn get_result_shape_of(
|
||||
//There is some code for that in the evaluator already.
|
||||
//One might reuse it.
|
||||
//For now we ignore this issue
|
||||
Ok(match op {
|
||||
match op {
|
||||
Operator::Equal
|
||||
| Operator::NotEqual
|
||||
| Operator::LessThan
|
||||
@ -258,7 +258,7 @@ fn get_result_shape_of(
|
||||
}
|
||||
Operator::Modulo => SyntaxShape::Number,
|
||||
Operator::Pow => SyntaxShape::Number,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn get_shape_of_expr(expr: &SpannedExpression) -> Option<SyntaxShape> {
|
||||
@ -334,7 +334,7 @@ fn get_result_shape_of_math_expr(
|
||||
//match lhs, rhs
|
||||
match (shapes[0], shapes[1]) {
|
||||
(None, None) | (None, _) | (_, None) => Ok(None),
|
||||
(Some(left), Some(right)) => get_result_shape_of(left, &bin.op, right).map(Some),
|
||||
(Some(left), Some(right)) => Ok(Some(get_result_shape_of(left, &bin.op, right))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Ansi {})?)
|
||||
test_examples(Ansi {})
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
pub struct Autoenv;
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
@ -20,7 +20,7 @@ impl Trusted {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn file_is_trusted(nu_env_file: &PathBuf, content: &[u8]) -> Result<bool, ShellError> {
|
||||
pub fn file_is_trusted(nu_env_file: &Path, content: &[u8]) -> Result<bool, ShellError> {
|
||||
let contentdigest = Sha256::digest(&content).as_slice().to_vec();
|
||||
let nufile = std::fs::canonicalize(nu_env_file)?;
|
||||
|
||||
|
@ -316,6 +316,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +337,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cal {})?)
|
||||
test_examples(Cal {})
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cd {})?)
|
||||
test_examples(Cd {})
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Char {})?)
|
||||
test_examples(Char {})
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Chart {})?)
|
||||
test_examples(Chart {})
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Clip {})?)
|
||||
test_examples(Clip {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Compact {})?)
|
||||
test_examples(Compact {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Count {})?)
|
||||
test_examples(Count {})
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Cpy {})?)
|
||||
test_examples(Cpy {})
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Date {})?)
|
||||
test_examples(Date {})
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Debug {})?)
|
||||
test_examples(Debug {})
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Default {})?)
|
||||
test_examples(Default {})
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Describe {})?)
|
||||
test_examples(Describe {})
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Do {})?)
|
||||
test_examples(Do {})
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Drop {})?)
|
||||
test_examples(Drop {})
|
||||
}
|
||||
}
|
||||
|
@ -168,6 +168,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Du {})?)
|
||||
test_examples(Du {})
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +160,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Each {})?)
|
||||
test_examples(Each {})
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(EachGroup {})?)
|
||||
test_examples(EachGroup {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(EachWindow {})?)
|
||||
test_examples(EachWindow {})
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Echo {})?)
|
||||
test_examples(Echo {})
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Enter {})?)
|
||||
test_examples(Enter {})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Every {})?)
|
||||
test_examples(Every {})
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Exit {})?)
|
||||
test_examples(Exit {})
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(First {})?)
|
||||
test_examples(First {})
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,7 @@ async fn flatten(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let (Arguments { rest: columns }, input) = args.process().await?;
|
||||
|
||||
Ok(input
|
||||
.map(move |item| {
|
||||
futures::stream::iter(flat_value(&columns, &item, &tag).into_iter().flatten())
|
||||
})
|
||||
.map(move |item| futures::stream::iter(flat_value(&columns, &item, &tag).into_iter()))
|
||||
.flatten()
|
||||
.to_output_stream())
|
||||
}
|
||||
@ -72,7 +70,7 @@ fn flat_value(
|
||||
columns: &[Tagged<String>],
|
||||
item: &Value,
|
||||
name_tag: impl Into<Tag>,
|
||||
) -> Result<Vec<Result<ReturnSuccess, ShellError>>, ShellError> {
|
||||
) -> Vec<Result<ReturnSuccess, ShellError>> {
|
||||
let tag = item.tag.clone();
|
||||
let name_tag = name_tag.into();
|
||||
|
||||
@ -121,7 +119,7 @@ fn flat_value(
|
||||
name_tag.span
|
||||
};
|
||||
|
||||
return Ok(vec![ReturnSuccess::value(
|
||||
return vec![ReturnSuccess::value(
|
||||
UntaggedValue::Error(ShellError::labeled_error_with_secondary(
|
||||
"can only flatten one inner table at the same time",
|
||||
"tried flattening more than one column with inner tables",
|
||||
@ -130,7 +128,7 @@ fn flat_value(
|
||||
already_flattened,
|
||||
))
|
||||
.into_value(name_tag),
|
||||
)]);
|
||||
)];
|
||||
}
|
||||
|
||||
if !columns.is_empty() {
|
||||
@ -179,5 +177,5 @@ fn flat_value(
|
||||
}
|
||||
};
|
||||
|
||||
Ok(res.into_iter().map(ReturnSuccess::value).collect())
|
||||
res.into_iter().map(ReturnSuccess::value).collect()
|
||||
}
|
||||
|
@ -145,6 +145,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Format {})?)
|
||||
test_examples(Format {})
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FileSize {})?)
|
||||
test_examples(FileSize {})
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(From {})?)
|
||||
test_examples(From {})
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromCSV {})?)
|
||||
test_examples(FromCSV {})
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromEML {})?)
|
||||
test_examples(FromEML {})
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +247,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromIcs {})?)
|
||||
test_examples(FromIcs {})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromINI {})?)
|
||||
test_examples(FromINI {})
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromJSON {})?)
|
||||
test_examples(FromJSON {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromODS {})?)
|
||||
test_examples(FromODS {})
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ fn from_ssv_string_to_value(
|
||||
aligned_columns: bool,
|
||||
split_at: usize,
|
||||
tag: impl Into<Tag>,
|
||||
) -> Option<Value> {
|
||||
) -> Value {
|
||||
let tag = tag.into();
|
||||
let rows = string_to_table(s, headerless, aligned_columns, split_at)
|
||||
.iter()
|
||||
@ -244,7 +244,7 @@ fn from_ssv_string_to_value(
|
||||
})
|
||||
.collect();
|
||||
|
||||
Some(UntaggedValue::Table(rows).into_value(&tag))
|
||||
UntaggedValue::Table(rows).into_value(&tag)
|
||||
}
|
||||
|
||||
async fn from_ssv(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
@ -271,23 +271,13 @@ async fn from_ssv(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
split_at,
|
||||
name.clone(),
|
||||
) {
|
||||
Some(x) => match x {
|
||||
Value {
|
||||
value: UntaggedValue::Table(list),
|
||||
..
|
||||
} => futures::stream::iter(list.into_iter().map(ReturnSuccess::value))
|
||||
.to_output_stream(),
|
||||
x => OutputStream::one(ReturnSuccess::value(x)),
|
||||
},
|
||||
None => {
|
||||
return Err(ShellError::labeled_error_with_secondary(
|
||||
"Could not parse as SSV",
|
||||
"input cannot be parsed ssv",
|
||||
&name,
|
||||
"value originates from here",
|
||||
&concat_string.tag,
|
||||
));
|
||||
Value {
|
||||
value: UntaggedValue::Table(list),
|
||||
..
|
||||
} => {
|
||||
futures::stream::iter(list.into_iter().map(ReturnSuccess::value)).to_output_stream()
|
||||
}
|
||||
x => OutputStream::one(ReturnSuccess::value(x)),
|
||||
},
|
||||
)
|
||||
}
|
||||
@ -502,6 +492,6 @@ mod tests {
|
||||
use super::FromSSV;
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromSSV {})?)
|
||||
test_examples(FromSSV {})
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromTOML {})?)
|
||||
test_examples(FromTOML {})
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromTSV {})?)
|
||||
test_examples(FromTSV {})
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromURL {})?)
|
||||
test_examples(FromURL {})
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromVcf {})?)
|
||||
test_examples(FromVcf {})
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromXLSX {})?)
|
||||
test_examples(FromXLSX {})
|
||||
}
|
||||
}
|
||||
|
@ -301,6 +301,6 @@ mod tests {
|
||||
use super::FromXML;
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromXML {})?)
|
||||
test_examples(FromXML {})
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ pub fn from_yaml_string_to_value(s: String, tag: impl Into<Tag>) -> Result<Value
|
||||
&tag,
|
||||
)
|
||||
})?;
|
||||
Ok(convert_yaml_value_to_nu_value(&v, tag)?)
|
||||
convert_yaml_value_to_nu_value(&v, tag)
|
||||
}
|
||||
|
||||
async fn from_yaml(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
@ -169,7 +169,7 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(FromYAML {})?)
|
||||
test_examples(FromYAML {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -139,6 +139,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(GroupByDate {})?)
|
||||
test_examples(GroupByDate {})
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Headers {})?)
|
||||
test_examples(Headers {})
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +217,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Help {})?)
|
||||
test_examples(Help {})
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +225,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Histogram {})?)
|
||||
test_examples(Histogram {})
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(History {})?)
|
||||
test_examples(History {})
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +137,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(If {})?)
|
||||
test_examples(If {})
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(IntoInt {})?)
|
||||
test_examples(IntoInt {})
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Kill {})?)
|
||||
test_examples(Kill {})
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Last {})?)
|
||||
test_examples(Last {})
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Lines {})?)
|
||||
test_examples(Lines {})
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Ls {})?)
|
||||
test_examples(Ls {})
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +187,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -113,6 +113,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -243,6 +243,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Merge {})?)
|
||||
test_examples(Merge {})
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Mkdir {})?)
|
||||
test_examples(Mkdir {})
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Mv {})?)
|
||||
test_examples(Mv {})
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ impl WholeStreamCommand for Next {
|
||||
}
|
||||
|
||||
async fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
next(args)
|
||||
Ok(next(args))
|
||||
}
|
||||
}
|
||||
|
||||
fn next(_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
Ok(vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into())
|
||||
fn next(_args: CommandArgs) -> OutputStream {
|
||||
vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -37,6 +37,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Next {})?)
|
||||
test_examples(Next {})
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Nth {})?)
|
||||
test_examples(Nth {})
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(SubCommand {})?)
|
||||
test_examples(SubCommand {})
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use nu_engine::WholeStreamCommand;
|
||||
use nu_errors::ShellError;
|
||||
use nu_protocol::{CommandAction, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
||||
use nu_source::{AnchorLocation, Span, Tagged};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct Open;
|
||||
|
||||
@ -180,13 +180,13 @@ async fn open(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
// Note that we do not output a Stream in "fetch" since it is only used by "enter" command
|
||||
// Which we expect to use a concrete Value a not a Stream
|
||||
pub async fn fetch(
|
||||
cwd: &PathBuf,
|
||||
location: &PathBuf,
|
||||
cwd: &Path,
|
||||
location: &Path,
|
||||
span: Span,
|
||||
encoding_choice: Option<Tagged<String>>,
|
||||
) -> Result<(Option<String>, Value), ShellError> {
|
||||
// TODO: I don't understand the point of this? Maybe for better error reporting
|
||||
let mut cwd = cwd.clone();
|
||||
let mut cwd = PathBuf::from(cwd);
|
||||
cwd.push(location);
|
||||
let nice_location = dunce::canonicalize(&cwd).map_err(|e| match e.kind() {
|
||||
std::io::ErrorKind::NotFound => ShellError::labeled_error(
|
||||
@ -254,6 +254,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Open {})?)
|
||||
test_examples(Open {})
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Command {})?)
|
||||
test_examples(Command {})
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathBasename {})?)
|
||||
test_examples(PathBasename {})
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(Path {})?)
|
||||
test_examples(Path {})
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathDirname {})?)
|
||||
test_examples(PathDirname {})
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathExists {})?)
|
||||
test_examples(PathExists {})
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathExpand {})?)
|
||||
test_examples(PathExpand {})
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathExtension {})?)
|
||||
test_examples(PathExtension {})
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +167,6 @@ mod tests {
|
||||
fn examples_work_as_expected() -> Result<(), ShellError> {
|
||||
use crate::examples::test as test_examples;
|
||||
|
||||
Ok(test_examples(PathFilestem {})?)
|
||||
test_examples(PathFilestem {})
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user