mirror of
https://github.com/nushell/nushell.git
synced 2025-05-29 14:21:45 +02:00
test Co-authored-by: Ricardo Monteiro <ricardo.monteiro@getmanta.com>
This commit is contained in:
parent
aed8d3800b
commit
c4cb3a77cb
@ -1,16 +1,18 @@
|
|||||||
use crate::filesystem::util::BufferedReader;
|
use crate::filesystem::util::BufferedReader;
|
||||||
use nu_engine::{eval_block, get_full_help, CallExt};
|
use nu_engine::{eval_block, CallExt};
|
||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, IntoPipelineData, PipelineData, RawStream, ShellError, Signature, Spanned,
|
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||||
SyntaxShape, Value,
|
|
||||||
};
|
};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::database::SQLiteDatabase;
|
use crate::database::SQLiteDatabase;
|
||||||
|
|
||||||
|
#[cfg(feature = "database")]
|
||||||
|
use nu_protocol::IntoPipelineData;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -67,29 +69,17 @@ impl Command for Open {
|
|||||||
// Collect a filename from the input
|
// Collect a filename from the input
|
||||||
match input {
|
match input {
|
||||||
PipelineData::Value(Value::Nothing { .. }, ..) => {
|
PipelineData::Value(Value::Nothing { .. }, ..) => {
|
||||||
return Ok(Value::String {
|
return Err(ShellError::MissingParameter(
|
||||||
val: get_full_help(
|
"needs filename".to_string(),
|
||||||
&Open.signature(),
|
call.head,
|
||||||
&Open.examples(),
|
))
|
||||||
engine_state,
|
|
||||||
stack,
|
|
||||||
),
|
|
||||||
span: call.head,
|
|
||||||
}
|
|
||||||
.into_pipeline_data())
|
|
||||||
}
|
}
|
||||||
PipelineData::Value(val, ..) => val.as_spanned_string()?,
|
PipelineData::Value(val, ..) => val.as_spanned_string()?,
|
||||||
_ => {
|
_ => {
|
||||||
return Ok(Value::String {
|
return Err(ShellError::MissingParameter(
|
||||||
val: get_full_help(
|
"needs filename".to_string(),
|
||||||
&Open.signature(),
|
call.head,
|
||||||
&Open.examples(),
|
));
|
||||||
engine_state,
|
|
||||||
stack,
|
|
||||||
),
|
|
||||||
span: call.head,
|
|
||||||
}
|
|
||||||
.into_pipeline_data())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -299,3 +299,15 @@ fn open_ignore_ansi() {
|
|||||||
assert!(actual.err.is_empty());
|
assert!(actual.err.is_empty());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn open_no_parameter() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: "tests/fixtures/formats",
|
||||||
|
r#"
|
||||||
|
open
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(actual.err.contains("needs filename"));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user