mirror of
https://github.com/nushell/nushell.git
synced 2025-03-16 00:18:34 +01: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 nu_engine::{eval_block, get_full_help, CallExt};
|
||||
use nu_engine::{eval_block, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoPipelineData, PipelineData, RawStream, ShellError, Signature, Spanned,
|
||||
SyntaxShape, Value,
|
||||
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
};
|
||||
use std::io::BufReader;
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use crate::database::SQLiteDatabase;
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use nu_protocol::IntoPipelineData;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
@ -67,29 +69,17 @@ impl Command for Open {
|
||||
// Collect a filename from the input
|
||||
match input {
|
||||
PipelineData::Value(Value::Nothing { .. }, ..) => {
|
||||
return Ok(Value::String {
|
||||
val: get_full_help(
|
||||
&Open.signature(),
|
||||
&Open.examples(),
|
||||
engine_state,
|
||||
stack,
|
||||
),
|
||||
span: call.head,
|
||||
}
|
||||
.into_pipeline_data())
|
||||
return Err(ShellError::MissingParameter(
|
||||
"needs filename".to_string(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
PipelineData::Value(val, ..) => val.as_spanned_string()?,
|
||||
_ => {
|
||||
return Ok(Value::String {
|
||||
val: get_full_help(
|
||||
&Open.signature(),
|
||||
&Open.examples(),
|
||||
engine_state,
|
||||
stack,
|
||||
),
|
||||
span: call.head,
|
||||
}
|
||||
.into_pipeline_data())
|
||||
return Err(ShellError::MissingParameter(
|
||||
"needs filename".to_string(),
|
||||
call.head,
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -299,3 +299,15 @@ fn open_ignore_ansi() {
|
||||
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…
Reference in New Issue
Block a user