mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 18:41:41 +02:00
Random fixes
This commit is contained in:
@ -57,7 +57,7 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
|
||||
let path = dunce::canonicalize(path)?;
|
||||
|
||||
let mut input = String::new();
|
||||
match reader.read_line(&mut input) {
|
||||
let result = match reader.read_line(&mut input) {
|
||||
Ok(count) => {
|
||||
trace!("processing response ({} bytes)", count);
|
||||
|
||||
@ -91,7 +91,9 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
|
||||
}
|
||||
}
|
||||
Err(e) => Err(ShellError::string(format!("Error: {:?}", e))),
|
||||
}
|
||||
};
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
fn load_plugins_in_dir(path: &std::path::PathBuf, context: &mut Context) -> Result<(), ShellError> {
|
||||
|
@ -186,6 +186,21 @@ pub async fn fetch(
|
||||
SpanSource::Url(location.to_string()),
|
||||
))
|
||||
}
|
||||
(mime::IMAGE, mime::SVG) => Ok((
|
||||
Some("svg".to_string()),
|
||||
Value::string(r.body_string().await.map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"Could not load svg from remote url",
|
||||
"could not load",
|
||||
span,
|
||||
)
|
||||
})?),
|
||||
Tag {
|
||||
span,
|
||||
origin: Some(Uuid::new_v4()),
|
||||
},
|
||||
SpanSource::Url(location.to_string()),
|
||||
)),
|
||||
(mime::IMAGE, image_ty) => {
|
||||
let buf: Vec<u8> = r.body_bytes().await.map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
|
@ -164,7 +164,7 @@ pub fn filter_plugin(
|
||||
let _ = stdin.write(format!("{}\n", request_raw).as_bytes()); // TODO: Handle error
|
||||
|
||||
let mut input = String::new();
|
||||
match reader.read_line(&mut input) {
|
||||
let result = match reader.read_line(&mut input) {
|
||||
Ok(_) => {
|
||||
let response = serde_json::from_str::<NuResult>(&input);
|
||||
match response {
|
||||
@ -201,7 +201,9 @@ pub fn filter_plugin(
|
||||
))));
|
||||
result
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
result
|
||||
}
|
||||
_ => {
|
||||
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
|
||||
|
@ -121,7 +121,7 @@ fn save(
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Save could not successfully save",
|
||||
"unexpected data during saveS",
|
||||
"unexpected data during save",
|
||||
name_span,
|
||||
));
|
||||
},
|
||||
@ -138,7 +138,7 @@ fn save(
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Save could not successfully save",
|
||||
"unexpected data during saveS",
|
||||
"unexpected data during save",
|
||||
name_span,
|
||||
));
|
||||
},
|
||||
@ -156,7 +156,7 @@ fn save(
|
||||
_ => {
|
||||
yield Err(ShellError::labeled_error(
|
||||
"Save could not successfully save",
|
||||
"unexpected data during saveS",
|
||||
"unexpected data during save",
|
||||
name_span,
|
||||
));
|
||||
},
|
||||
|
@ -22,7 +22,7 @@ pub trait Plugin {
|
||||
#[allow(unused)]
|
||||
fn sink(&mut self, call_info: CallInfo, input: Vec<Tagged<Value>>) {}
|
||||
|
||||
fn quit(&mut self) {}
|
||||
fn quit(&mut self){}
|
||||
}
|
||||
|
||||
pub fn serve_plugin(plugin: &mut dyn Plugin) {
|
||||
@ -43,6 +43,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
|
||||
match command {
|
||||
Ok(NuCommand::config) => {
|
||||
send_response(plugin.config());
|
||||
return;
|
||||
}
|
||||
Ok(NuCommand::begin_filter { params }) => {
|
||||
send_response(plugin.begin_filter(params));
|
||||
@ -52,6 +53,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
|
||||
}
|
||||
Ok(NuCommand::end_filter) => {
|
||||
send_response(plugin.end_filter());
|
||||
return;
|
||||
}
|
||||
|
||||
Ok(NuCommand::sink { params }) => {
|
||||
@ -80,6 +82,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
|
||||
match command {
|
||||
Ok(NuCommand::config) => {
|
||||
send_response(plugin.config());
|
||||
break;
|
||||
}
|
||||
Ok(NuCommand::begin_filter { params }) => {
|
||||
send_response(plugin.begin_filter(params));
|
||||
@ -89,6 +92,7 @@ pub fn serve_plugin(plugin: &mut dyn Plugin) {
|
||||
}
|
||||
Ok(NuCommand::end_filter) => {
|
||||
send_response(plugin.end_filter());
|
||||
break;
|
||||
}
|
||||
Ok(NuCommand::sink { params }) => {
|
||||
plugin.sink(params.0, params.1);
|
||||
|
Reference in New Issue
Block a user