Make sure that scripts can also have custom commands. (#3309)

With the current code it is possible to attach custom commands from
a custom binary, but only for interactive mode. This change makes
it possible to also customize the evaluation context for commands
and scripts.
This commit is contained in:
Michael Nitschinger
2021-04-14 20:21:50 +02:00
committed by GitHub
parent a92ff57270
commit e8bc319f08
2 changed files with 5 additions and 6 deletions

View File

@ -150,7 +150,8 @@ fn main() -> Result<(), Box<dyn Error>> {
Some(values) => {
options.scripts = vec![NuScript::code(values)?];
nu_cli::run_script_file(options)?;
let context = create_default_context(false)?;
nu_cli::run_script_file(context, options)?;
return Ok(());
}
}
@ -161,7 +162,8 @@ fn main() -> Result<(), Box<dyn Error>> {
options.scripts = vec![NuScript::source_file(filepath.as_os_str())?];
nu_cli::run_script_file(options)?;
let context = create_default_context(false)?;
nu_cli::run_script_file(context, options)?;
return Ok(());
}