Add string stream and binary stream, add text decoding (#570)

* WIP

* Add binary/string streams and text decoding

* Make string collection fallible

* Oops, forgot pretty hex

* Oops, forgot pretty hex

* clippy
This commit is contained in:
JT
2021-12-24 18:22:11 +11:00
committed by GitHub
parent 7f0921a14b
commit 3522bead97
50 changed files with 1633 additions and 119 deletions

View File

@ -583,6 +583,28 @@ fn print_pipeline_data(
let config = stack.get_config().unwrap_or_default();
match input {
PipelineData::StringStream(stream, _, _) => {
for s in stream {
print!("{}", s?);
let _ = std::io::stdout().flush();
}
return Ok(());
}
PipelineData::ByteStream(stream, _, _) => {
for v in stream {
let s = if v.iter().all(|x| x.is_ascii()) {
format!("{}", String::from_utf8_lossy(&v))
} else {
format!("{}\n", nu_pretty_hex::pretty_hex(&v))
};
println!("{}", s);
}
return Ok(());
}
_ => {}
}
match engine_state.find_decl("table".as_bytes()) {
Some(decl_id) => {
let table =
@ -663,7 +685,12 @@ fn update_prompt<'prompt>(
}
};
nu_prompt.update_prompt(evaluated_prompt);
match evaluated_prompt {
Ok(evaluated_prompt) => {
nu_prompt.update_prompt(evaluated_prompt);
}
_ => nu_prompt.update_prompt(String::new()),
}
nu_prompt as &dyn Prompt
}