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,
|
2019-11-24 00:56:19 +00:00
|
|
|
RunnableContext { input, .. }: RunnableContext,
|
2019-11-22 08:31:58 +00:00
|
|
|
) -> Result<impl ToOutputStream, ShellError> {
|
2019-11-24 00:56:19 +00:00
|
|
|
Ok(input
|
|
|
|
.values
|
|
|
|
.map(|v| ReturnSuccess::value(Value::string(format!("{:?}", v)).tagged_unknown()))
|
|
|
|
.to_output_stream())
|
2019-08-12 05:51:13 +00:00
|
|
|
}
|