It-expansion fixes (#1757)

* It-expansion fixes

* fix clippy
This commit is contained in:
Jonathan Turner
2020-05-12 15:58:16 +12:00
committed by GitHub
parent 8b9a8daa1d
commit c3535b5c67
5 changed files with 49 additions and 6 deletions

View File

@ -3,6 +3,7 @@ use crate::prelude::*;
use log::{log_enabled, trace};
use futures::stream::once;
use nu_errors::ShellError;
use nu_protocol::hir::SpannedExpression;
use nu_protocol::Scope;
@ -10,7 +11,7 @@ use nu_protocol::Scope;
pub(crate) fn run_expression_block(
expr: SpannedExpression,
context: &mut Context,
input: InputStream,
_input: InputStream,
scope: &Scope,
) -> Result<InputStream, ShellError> {
if log_enabled!(log::Level::Trace) {
@ -20,10 +21,7 @@ pub(crate) fn run_expression_block(
let scope = scope.clone();
let registry = context.registry().clone();
let stream = input.map(move |row| {
let scope = scope.clone().set_it(row);
evaluate_baseline_expr(&expr, &registry, &scope)
});
let output = evaluate_baseline_expr(&expr, &registry, &scope)?;
Ok(stream.to_input_stream())
Ok(once(async { Ok(output) }).to_input_stream())
}

View File

@ -33,6 +33,19 @@ impl WholeStreamCommand for Date {
) -> Result<OutputStream, ShellError> {
date(args, registry)
}
fn examples(&self) -> &[Example] {
&[
Example {
description: "Get the current local time and date",
example: "date",
},
Example {
description: "Get the current UTC time and date",
example: "date --utc",
},
]
}
}
pub fn date_to_value<T: TimeZone>(dt: DateTime<T>, tag: Tag) -> Value