Add table streaming (#413)

This commit is contained in:
JT
2021-12-03 19:15:23 +13:00
committed by GitHub
parent 3d8394a909
commit 574d7f6936
3 changed files with 161 additions and 25 deletions

View File

@ -226,6 +226,7 @@ impl ExternalCommand {
let mut process = std::process::Command::new(&self.name.item);
for arg in &self.args {
let arg = trim_enclosing_quotes(arg);
process.arg(&arg);
}
@ -275,6 +276,16 @@ fn shell_arg_escape(arg: &str) -> String {
}
}
fn trim_enclosing_quotes(input: &str) -> String {
let mut chars = input.chars();
match (chars.next(), chars.next_back()) {
(Some('"'), Some('"')) => chars.collect(),
(Some('\''), Some('\'')) => chars.collect(),
_ => input.to_string(),
}
}
// The piped data from stdout from the external command can be either String
// or binary. We use this enum to pass the data from the spawned process
#[derive(Debug)]