mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Plugins without file (#4650)
* adding plugin location in script * adding plugin location in script
This commit is contained in:
parent
ed46f0ea17
commit
3eca43c0bb
2 changed files with 20 additions and 5 deletions
|
@ -19,12 +19,10 @@ const PLUGIN_FILE: &str = "plugin.nu";
|
||||||
pub(crate) fn read_plugin_file(engine_state: &mut EngineState, stack: &mut Stack) {
|
pub(crate) fn read_plugin_file(engine_state: &mut EngineState, stack: &mut Stack) {
|
||||||
// Reading signatures from signature file
|
// Reading signatures from signature file
|
||||||
// The plugin.nu file stores the parsed signature collected from each registered plugin
|
// The plugin.nu file stores the parsed signature collected from each registered plugin
|
||||||
if let Some(mut plugin_path) = nu_path::config_dir() {
|
add_plugin_file(engine_state);
|
||||||
// Path to store plugins signatures
|
|
||||||
plugin_path.push(NUSHELL_FOLDER);
|
|
||||||
plugin_path.push(PLUGIN_FILE);
|
|
||||||
engine_state.plugin_signatures = Some(plugin_path.clone());
|
|
||||||
|
|
||||||
|
let plugin_path = engine_state.plugin_signatures.clone();
|
||||||
|
if let Some(plugin_path) = plugin_path {
|
||||||
let plugin_filename = plugin_path.to_string_lossy().to_owned();
|
let plugin_filename = plugin_path.to_string_lossy().to_owned();
|
||||||
|
|
||||||
if let Ok(contents) = std::fs::read(&plugin_path) {
|
if let Ok(contents) = std::fs::read(&plugin_path) {
|
||||||
|
@ -37,11 +35,22 @@ pub(crate) fn read_plugin_file(engine_state: &mut EngineState, stack: &mut Stack
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true() {
|
if is_perf_true() {
|
||||||
info!("read_plugin_file {}:{}:{}", file!(), line!(), column!());
|
info!("read_plugin_file {}:{}:{}", file!(), line!(), column!());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
pub(crate) fn add_plugin_file(engine_state: &mut EngineState) {
|
||||||
|
if let Some(mut plugin_path) = nu_path::config_dir() {
|
||||||
|
// Path to store plugins signatures
|
||||||
|
plugin_path.push(NUSHELL_FOLDER);
|
||||||
|
plugin_path.push(PLUGIN_FILE);
|
||||||
|
engine_state.plugin_signatures = Some(plugin_path.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn read_config_file(
|
pub(crate) fn read_config_file(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
|
|
|
@ -191,6 +191,9 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(commands) = &binary_args.commands {
|
if let Some(commands) = &binary_args.commands {
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
config_files::add_plugin_file(&mut engine_state);
|
||||||
|
|
||||||
let ret_val = commands::evaluate(commands, &init_cwd, &mut engine_state, input);
|
let ret_val = commands::evaluate(commands, &init_cwd, &mut engine_state, input);
|
||||||
if is_perf_true() {
|
if is_perf_true() {
|
||||||
info!("-c command execution {}:{}:{}", file!(), line!(), column!());
|
info!("-c command execution {}:{}:{}", file!(), line!(), column!());
|
||||||
|
@ -198,6 +201,9 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
} else if !script_name.is_empty() && binary_args.interactive_shell.is_none() {
|
} else if !script_name.is_empty() && binary_args.interactive_shell.is_none() {
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
config_files::add_plugin_file(&mut engine_state);
|
||||||
|
|
||||||
let ret_val =
|
let ret_val =
|
||||||
eval_file::evaluate(script_name, &args_to_script, &mut engine_state, input);
|
eval_file::evaluate(script_name, &args_to_script, &mut engine_state, input);
|
||||||
if is_perf_true() {
|
if is_perf_true() {
|
||||||
|
|
Loading…
Reference in a new issue