Remove --encoding argument during register plugin (#6486)

* first implement new plugin protocol core logic

* fix debug body construct

* fix output message from plugin

* finish plugin commands calling

* fix tests and adjust plugin_custom_value call

* fmt code

* fmt code, fix clippy

* add FIXME comment

* change from FIXME to TODO
This commit is contained in:
WindSoilder
2022-09-07 22:07:42 +08:00
committed by GitHub
parent 80624267fd
commit aa92141ad7
12 changed files with 142 additions and 125 deletions

View File

@@ -3,10 +3,7 @@ use std::path::PathBuf;
use nu_protocol::{CustomValue, ShellError, Value};
use serde::Serialize;
use crate::{
plugin::{call_plugin, create_command},
EncodingType,
};
use crate::plugin::{call_plugin, create_command, get_plugin_encoding};
use super::{PluginCall, PluginData, PluginResponse};
@@ -32,8 +29,6 @@ pub struct PluginCustomValue {
#[serde(skip)]
pub shell: Option<PathBuf>,
#[serde(skip)]
pub encoding: EncodingType,
#[serde(skip)]
pub source: String,
}
@@ -72,8 +67,19 @@ impl CustomValue for PluginCustomValue {
data: self.data.clone(),
span,
});
let encoding = {
let stdout_reader = match &mut child.stdout {
Some(out) => out,
None => {
return Err(ShellError::PluginFailedToLoad(
"Plugin missing stdout reader".into(),
))
}
};
get_plugin_encoding(stdout_reader)?
};
let response = call_plugin(&mut child, plugin_call, &self.encoding, span).map_err(|err| {
let response = call_plugin(&mut child, plugin_call, &encoding, span).map_err(|err| {
ShellError::GenericError(
format!(
"Unable to decode call for {} to get base value",