mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Pretty Nu print default, pretty print regular secondary as raw flag. (#1302)
This commit is contained in:
parent
8ef5c47515
commit
ac5ad45783
1 changed files with 13 additions and 5 deletions
|
@ -6,7 +6,9 @@ use nu_protocol::{ReturnSuccess, Signature, UntaggedValue};
|
||||||
pub struct Debug;
|
pub struct Debug;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct DebugArgs {}
|
pub struct DebugArgs {
|
||||||
|
raw: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl WholeStreamCommand for Debug {
|
impl WholeStreamCommand for Debug {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
|
@ -14,7 +16,7 @@ impl WholeStreamCommand for Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("debug")
|
Signature::build("debug").switch("raw", "Prints the raw value representation.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -31,13 +33,19 @@ impl WholeStreamCommand for Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_value(
|
fn debug_value(
|
||||||
_args: DebugArgs,
|
DebugArgs { raw }: DebugArgs,
|
||||||
RunnableContext { input, .. }: RunnableContext,
|
RunnableContext { input, .. }: RunnableContext,
|
||||||
) -> Result<impl ToOutputStream, ShellError> {
|
) -> Result<impl ToOutputStream, ShellError> {
|
||||||
Ok(input
|
Ok(input
|
||||||
.values
|
.values
|
||||||
.map(|v| {
|
.map(move |v| {
|
||||||
ReturnSuccess::value(UntaggedValue::string(format!("{:#?}", v)).into_untagged_value())
|
if raw {
|
||||||
|
ReturnSuccess::value(
|
||||||
|
UntaggedValue::string(format!("{:#?}", v)).into_untagged_value(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ReturnSuccess::debug_value(v)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.to_output_stream())
|
.to_output_stream())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue