mirror of
https://github.com/nushell/nushell
synced 2025-01-15 22:54:16 +00:00
Removed extra file
This commit is contained in:
parent
719920fa37
commit
2b5ef1b2d7
2 changed files with 70 additions and 70 deletions
|
@ -32,86 +32,87 @@ impl Command for Source {
|
||||||
call: &Call,
|
call: &Call,
|
||||||
input: Value,
|
input: Value,
|
||||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||||
source(_context, call, input)
|
Ok(Value::Nothing { span: call.head })
|
||||||
|
// source(_context, call, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source(ctx: &EvaluationContext, call: &Call, input: Value) -> Result<Value, ShellError> {
|
// pub fn source(ctx: &EvaluationContext, call: &Call, input: Value) -> Result<Value, ShellError> {
|
||||||
let filename = call.positional[0]
|
// let filename = call.positional[0]
|
||||||
.as_string()
|
// .as_string()
|
||||||
.expect("internal error: missing file name");
|
// .expect("internal error: missing file name");
|
||||||
|
|
||||||
let source_file = Path::new(&filename);
|
// let source_file = Path::new(&filename);
|
||||||
|
|
||||||
// This code is in the current Nushell version
|
// // This code is in the current Nushell version
|
||||||
// ...Not entirely sure what it's doing or if there's an equivalent in engine-q
|
// // ...Not entirely sure what it's doing or if there's an equivalent in engine-q
|
||||||
|
|
||||||
// Note: this is a special case for setting the context from a command
|
// // Note: this is a special case for setting the context from a command
|
||||||
// In this case, if we don't set it now, we'll lose the scope that this
|
// // In this case, if we don't set it now, we'll lose the scope that this
|
||||||
// variable should be set into.
|
// // variable should be set into.
|
||||||
|
|
||||||
// let lib_dirs = &ctx
|
// // let lib_dirs = &ctx
|
||||||
// .configs()
|
// // .configs()
|
||||||
// .lock()
|
// // .lock()
|
||||||
// .global_config
|
// // .global_config
|
||||||
// .as_ref()
|
// // .as_ref()
|
||||||
// .map(|configuration| match configuration.var("lib_dirs") {
|
// // .map(|configuration| match configuration.var("lib_dirs") {
|
||||||
// Some(paths) => paths
|
// // Some(paths) => paths
|
||||||
// .table_entries()
|
// // .table_entries()
|
||||||
// .cloned()
|
// // .cloned()
|
||||||
// .map(|path| path.as_string())
|
// // .map(|path| path.as_string())
|
||||||
// .collect(),
|
// // .collect(),
|
||||||
// None => vec![],
|
// // None => vec![],
|
||||||
// });
|
// // });
|
||||||
|
|
||||||
// if let Some(dir) = lib_dirs {
|
// // if let Some(dir) = lib_dirs {
|
||||||
// for lib_path in dir {
|
// // for lib_path in dir {
|
||||||
// match lib_path {
|
// // match lib_path {
|
||||||
// Ok(name) => {
|
// // Ok(name) => {
|
||||||
// let path = PathBuf::from(name).join(source_file);
|
// // let path = PathBuf::from(name).join(source_file);
|
||||||
|
|
||||||
// if let Ok(contents) =
|
// // if let Ok(contents) =
|
||||||
// std::fs::read_to_string(&expand_path(Cow::Borrowed(path.as_path())))
|
// // std::fs::read_to_string(&expand_path(Cow::Borrowed(path.as_path())))
|
||||||
// {
|
// // {
|
||||||
// let result = script::run_script_standalone(contents, true, ctx, false);
|
// // let result = script::run_script_standalone(contents, true, ctx, false);
|
||||||
|
|
||||||
// if let Err(err) = result {
|
// // if let Err(err) = result {
|
||||||
// ctx.error(err);
|
// // ctx.error(err);
|
||||||
// }
|
// // }
|
||||||
// return Ok(OutputStream::empty());
|
// // return Ok(OutputStream::empty());
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
// Err(reason) => {
|
// // Err(reason) => {
|
||||||
// ctx.error(reason.clone());
|
// // ctx.error(reason.clone());
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// This is to stay consistent w/ the code taken from nushell
|
// // This is to stay consistent w/ the code taken from nushell
|
||||||
let path = source_file;
|
// let path = source_file;
|
||||||
|
|
||||||
let contents = std::fs::read(path);
|
// let contents = std::fs::read(path);
|
||||||
|
|
||||||
match contents {
|
// match contents {
|
||||||
Ok(contents) => {
|
// Ok(contents) => {
|
||||||
let engine_state = EngineState::new();
|
// let engine_state = EngineState::new();
|
||||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
// let mut working_set = StateWorkingSet::new(&engine_state);
|
||||||
|
|
||||||
let (block, err) = parse(&mut working_set, None, &contents, true);
|
// let (block, err) = parse(&mut working_set, None, &contents, true);
|
||||||
if let Some(e) = err {
|
// if let Some(e) = err {
|
||||||
// Be more specific here: need to convert parse error to string
|
// // Be more specific here: need to convert parse error to string
|
||||||
Err(e.into())
|
// Err(e.into())
|
||||||
} else {
|
// } else {
|
||||||
let result = eval_block(ctx, &block, input);
|
// let result = eval_block(ctx, &block, input);
|
||||||
match result {
|
// match result {
|
||||||
Err(e) => Err(e),
|
// Err(e) => Err(e),
|
||||||
_ => Ok(Value::nothing()),
|
// _ => Ok(Value::nothing()),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Err(_) => Err(ShellError::InternalError(
|
// Err(_) => Err(ShellError::InternalError(
|
||||||
"Can't load file to source".to_string(),
|
// "Can't load file to source".to_string(),
|
||||||
)),
|
// )),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
length [1,2,3,4]
|
|
Loading…
Reference in a new issue