mirror of
https://github.com/nushell/nushell
synced 2024-12-25 12:33:17 +00:00
More stream stuff
This commit is contained in:
parent
e6da37f5be
commit
786da8fd9d
2 changed files with 36 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
use crate::object::Value;
|
||||
use derive_new::new;
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -7,20 +8,46 @@ pub struct ObjectStream {
|
|||
queue: VecDeque<Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Streams {
|
||||
success: ObjectStream,
|
||||
error: ObjectStream,
|
||||
warning: ObjectStream,
|
||||
debug: ObjectStream,
|
||||
trace: ObjectStream,
|
||||
verbose: ObjectStream,
|
||||
success: Cell<ObjectStream>,
|
||||
// error: ObjectStream,
|
||||
// warning: ObjectStream,
|
||||
// debug: ObjectStream,
|
||||
// trace: ObjectStream,
|
||||
// verbose: ObjectStream,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Streams {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "Streams")
|
||||
}
|
||||
}
|
||||
|
||||
impl Streams {
|
||||
crate fn new() -> Streams {
|
||||
Streams {
|
||||
success: Cell::new(ObjectStream::default()),
|
||||
}
|
||||
}
|
||||
|
||||
crate fn take_success(&mut self) -> Cell<ObjectStream> {
|
||||
let new_stream = Cell::new(ObjectStream::default());
|
||||
self.success.swap(&new_stream);
|
||||
new_stream
|
||||
}
|
||||
|
||||
// fn take_stream(&mut self, stream: &mut ObjectStream) -> ObjectStream {
|
||||
// let mut new_stream = Cell::new(ObjectStream::default());
|
||||
// new_stream.swap()
|
||||
// std::mem::swap(stream, &mut new_stream);
|
||||
// new_stream
|
||||
// }
|
||||
}
|
||||
|
||||
#[derive(Debug, new)]
|
||||
pub struct Args {
|
||||
argv: Vec<Value>,
|
||||
#[new(default)]
|
||||
#[new(value = "Streams::new()")]
|
||||
streams: Streams,
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||
pub trait CommandBlueprint {
|
||||
fn create(
|
||||
&self,
|
||||
args: crate::Args,
|
||||
input: crate::Args,
|
||||
host: &dyn crate::Host,
|
||||
env: &mut crate::Environment,
|
||||
) -> Result<Box<dyn Command>, ShellError>;
|
||||
|
|
Loading…
Reference in a new issue