mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 02:09:04 +02:00
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:
29
src/main.rs
29
src/main.rs
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user