mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 18:42:42 +02:00
Plugin json (#474)
* json encoder * thread to pass messages * description for example
This commit is contained in:
@ -48,8 +48,8 @@ pub trait Command: Send + Sync + CommandClone {
|
||||
self.name().contains(' ')
|
||||
}
|
||||
|
||||
// Is a plugin command (returns plugin's name if yes)
|
||||
fn is_plugin(&self) -> Option<&PathBuf> {
|
||||
// Is a plugin command (returns plugin's path and encoding if yes)
|
||||
fn is_plugin(&self) -> Option<(&PathBuf, &str)> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -230,11 +230,13 @@ impl EngineState {
|
||||
self.plugin_decls().try_for_each(|decl| {
|
||||
// A successful plugin registration already includes the plugin filename
|
||||
// No need to check the None option
|
||||
let path = decl.is_plugin().expect("plugin should have file name");
|
||||
let (path, encoding) = decl.is_plugin().expect("plugin should have file name");
|
||||
let file_name = path.to_str().expect("path should be a str");
|
||||
|
||||
serde_json::to_string_pretty(&decl.signature())
|
||||
.map(|signature| format!("register {} {}\n\n", file_name, signature))
|
||||
.map(|signature| {
|
||||
format!("register {} -e {} {}\n\n", file_name, encoding, signature)
|
||||
})
|
||||
.map_err(|err| ShellError::PluginFailedToLoad(err.to_string()))
|
||||
.and_then(|line| {
|
||||
plugin_file
|
||||
|
Reference in New Issue
Block a user