nushell/src/commands/debug.rs

43 lines
916 B
Rust
Raw Normal View History

use crate::commands::WholeStreamCommand;
use crate::prelude::*;
pub struct Debug;
2019-11-22 09:31:58 +01:00
#[derive(Deserialize)]
pub struct DebugArgs {}
impl WholeStreamCommand for Debug {
fn name(&self) -> &str {
"debug"
}
fn signature(&self) -> Signature {
Signature::build("debug")
}
fn usage(&self) -> &str {
2019-11-22 09:31:58 +01:00
"Print the Rust debug representation of the values"
}
fn run(
&self,
args: CommandArgs,
registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
2019-11-22 09:31:58 +01:00
args.process(registry, debug_value)?.run()
}
}
2019-11-22 09:31:58 +01: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-11-22 09:31:58 +01:00
Ok(stream)
}