mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Display raw debugging data (rust represetantion).
This commit is contained in:
parent
e85e1b2c9e
commit
8d3a937413
1 changed files with 13 additions and 6 deletions
|
@ -4,7 +4,9 @@ use crate::prelude::*;
|
|||
pub struct Debug;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct DebugArgs {}
|
||||
pub struct DebugArgs {
|
||||
raw: Tagged<bool>,
|
||||
}
|
||||
|
||||
impl WholeStreamCommand for Debug {
|
||||
fn name(&self) -> &str {
|
||||
|
@ -12,7 +14,7 @@ impl WholeStreamCommand for Debug {
|
|||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("debug")
|
||||
Signature::build("debug").switch("raw", "print raw data")
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -29,14 +31,19 @@ impl WholeStreamCommand for Debug {
|
|||
}
|
||||
|
||||
fn debug_value(
|
||||
_args: DebugArgs,
|
||||
DebugArgs { raw }: DebugArgs,
|
||||
RunnableContext { mut input, .. }: RunnableContext,
|
||||
) -> Result<impl ToOutputStream, ShellError> {
|
||||
) -> Result<OutputStream, ShellError> {
|
||||
let stream = async_stream! {
|
||||
while let Some(row) = input.values.next().await {
|
||||
if let Tagged { item: true, .. } = raw {
|
||||
println!("{:?}", row);
|
||||
yield ReturnSuccess::value(row)
|
||||
} else {
|
||||
yield ReturnSuccess::debug_value(row.clone())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(stream)
|
||||
Ok(stream.to_output_stream())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue