Move Value to helpers, separate span call (#10121)

# Description

As part of the refactor to split spans off of Value, this moves to using
helper functions to create values, and using `.span()` instead of
matching span out of Value directly.

Hoping to get a few more helping hands to finish this, as there are a
lot of commands to update :)

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# 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` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# 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.
-->

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: WindSoilder <windsoilder@outlook.com>
This commit is contained in:
JT
2023-09-04 02:27:29 +12:00
committed by GitHub
parent af79eb2943
commit 6cdfee3573
372 changed files with 5811 additions and 7448 deletions

View File

@ -78,8 +78,8 @@ impl Command for SeqDate {
Example {
description: "print the first 10 days in January, 2020",
example: "seq date -b '2020-01-01' -e '2020-01-10'",
result: Some(Value::List {
vals: vec![
result: Some(Value::list(
vec![
Value::test_string("2020-01-01"),
Value::test_string("2020-01-02"),
Value::test_string("2020-01-03"),
@ -91,14 +91,14 @@ impl Command for SeqDate {
Value::test_string("2020-01-09"),
Value::test_string("2020-01-10"),
],
span: Span::test_data(),
}),
Span::test_data(),
)),
},
Example {
description: "print every fifth day between January 1st 2020 and January 31st 2020",
example: "seq date -b '2020-01-01' -e '2020-01-31' -n 5",
result: Some(Value::List {
vals: vec![
result: Some(Value::list(
vec![
Value::test_string("2020-01-01"),
Value::test_string("2020-01-06"),
Value::test_string("2020-01-11"),
@ -107,8 +107,8 @@ impl Command for SeqDate {
Value::test_string("2020-01-26"),
Value::test_string("2020-01-31"),
],
span: Span::test_data(),
}),
Span::test_data(),
)),
},
]
}
@ -324,10 +324,7 @@ pub fn run_seq_dates(
}
}
Ok(Value::List {
vals: ret,
span: call_span,
})
Ok(Value::list(ret, call_span))
}
#[cfg(test)]