2019-08-19 05:16:39 +00:00
|
|
|
use crate::commands::WholeStreamCommand;
|
2019-08-12 05:51:13 +00:00
|
|
|
use crate::prelude::*;
|
|
|
|
|
2019-08-19 05:16:39 +00:00
|
|
|
pub struct Debug;
|
|
|
|
|
2019-11-22 08:31:58 +00:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct DebugArgs {}
|
|
|
|
|
2019-08-19 05:16:39 +00:00
|
|
|
impl WholeStreamCommand for Debug {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"debug"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("debug")
|
|
|
|
}
|
2019-08-29 22:52:32 +00:00
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
2019-11-22 08:31:58 +00:00
|
|
|
"Print the Rust debug representation of the values"
|
2019-08-29 22:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
2019-11-22 08:31:58 +00:00
|
|
|
args.process(registry, debug_value)?.run()
|
2019-08-29 22:52:32 +00:00
|
|
|
}
|
2019-08-19 05:16:39 +00:00
|
|
|
}
|
|
|
|
|
2019-11-22 08:31:58 +00:00
|
|
|
fn debug_value(
|
|
|
|
_args: DebugArgs,
|
|
|
|
RunnableContext { mut input, .. }: RunnableContext,
|
|
|
|
) -> Result<impl ToOutputStream, ShellError> {
|
|
|
|
let stream = async_stream! {
|
|
|
|
while let Some(row) = input.values.next().await {
|
|
|
|
yield ReturnSuccess::debug_value(row.clone())
|
|
|
|
}
|
|
|
|
};
|
2019-08-12 05:51:13 +00:00
|
|
|
|
2019-11-22 08:31:58 +00:00
|
|
|
Ok(stream)
|
2019-08-12 05:51:13 +00:00
|
|
|
}
|