mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Load plugin if and only if it hasn't been registered.
This commit is contained in:
parent
7d41ac54b5
commit
95ea3fcf4e
1 changed files with 15 additions and 13 deletions
20
src/cli.rs
20
src/cli.rs
|
@ -72,21 +72,23 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
|
||||||
|
|
||||||
trace!("processing {:?}", params);
|
trace!("processing {:?}", params);
|
||||||
|
|
||||||
if params.is_filter {
|
|
||||||
let fname = fname.to_string();
|
|
||||||
let name = params.name.clone();
|
let name = params.name.clone();
|
||||||
context.add_commands(vec![whole_stream_command(PluginCommand::new(
|
let fname = fname.to_string();
|
||||||
name, fname, params,
|
|
||||||
))]);
|
if context.has_command(&name) {
|
||||||
Ok(())
|
trace!("plugin {:?} already loaded.", &name);
|
||||||
|
} else {
|
||||||
|
if params.is_filter {
|
||||||
|
context.add_commands(vec![whole_stream_command(
|
||||||
|
PluginCommand::new(name, fname, params),
|
||||||
|
)]);
|
||||||
} else {
|
} else {
|
||||||
let fname = fname.to_string();
|
|
||||||
let name = params.name.clone();
|
|
||||||
context.add_commands(vec![whole_stream_command(PluginSink::new(
|
context.add_commands(vec![whole_stream_command(PluginSink::new(
|
||||||
name, fname, params,
|
name, fname, params,
|
||||||
))]);
|
))]);
|
||||||
Ok(())
|
};
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue