mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Merge pull request #697 from andrasio/plugin-loadone
Load plugin if and only if it hasn't been registered.
This commit is contained in:
commit
c7b9db0523
1 changed files with 15 additions and 13 deletions
28
src/cli.rs
28
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 name = params.name.clone();
|
||||||
let fname = fname.to_string();
|
let fname = fname.to_string();
|
||||||
let name = params.name.clone();
|
|
||||||
context.add_commands(vec![whole_stream_command(PluginCommand::new(
|
if context.has_command(&name) {
|
||||||
name, fname, params,
|
trace!("plugin {:?} already loaded.", &name);
|
||||||
))]);
|
|
||||||
Ok(())
|
|
||||||
} else {
|
} else {
|
||||||
let fname = fname.to_string();
|
if params.is_filter {
|
||||||
let name = params.name.clone();
|
context.add_commands(vec![whole_stream_command(
|
||||||
context.add_commands(vec![whole_stream_command(PluginSink::new(
|
PluginCommand::new(name, fname, params),
|
||||||
name, fname, params,
|
)]);
|
||||||
))]);
|
} else {
|
||||||
Ok(())
|
context.add_commands(vec![whole_stream_command(PluginSink::new(
|
||||||
|
name, fname, params,
|
||||||
|
))]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue