From 3be7996e79b5e996a6b93c970ddfbac1f4505057 Mon Sep 17 00:00:00 2001
From: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Date: Fri, 23 Dec 2022 15:56:28 -0600
Subject: [PATCH] add metadata to wrap (#7586)
# Description
This PR allows `wrap` to pass through metadata.
# User-Facing Changes
This change allows this:
Instead of this:
Strangely enough, this command doesn't result in LS_COLORS `(ls |
values).0 | wrap name`
/cc @webbedspace - we were talking about LS_COLORS in `values` earlier.
# Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
# After Submitting
If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
---
crates/nu-command/src/filters/wrap.rs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/crates/nu-command/src/filters/wrap.rs b/crates/nu-command/src/filters/wrap.rs
index 545532c0aa..41a07e573d 100644
--- a/crates/nu-command/src/filters/wrap.rs
+++ b/crates/nu-command/src/filters/wrap.rs
@@ -37,6 +37,7 @@ impl Command for Wrap {
) -> Result {
let span = call.head;
let name: String = call.req(engine_state, stack, 0)?;
+ let metadata = input.metadata();
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
@@ -49,19 +50,22 @@ impl Command for Wrap {
vals: vec![x],
span,
})
- .into_pipeline_data(engine_state.ctrlc.clone())),
+ .into_pipeline_data(engine_state.ctrlc.clone())
+ .set_metadata(metadata)),
PipelineData::ExternalStream { .. } => Ok(Value::Record {
cols: vec![name],
vals: vec![input.into_value(call.head)],
span,
}
- .into_pipeline_data()),
+ .into_pipeline_data()
+ .set_metadata(metadata)),
PipelineData::Value(input, ..) => Ok(Value::Record {
cols: vec![name],
vals: vec![input],
span,
}
- .into_pipeline_data()),
+ .into_pipeline_data()
+ .set_metadata(metadata)),
}
}