fix main not building due to errors later found in describe (#10821)

# Description

This is just a fixup PR. There was a describe PR that passed CI but then
later didn't pass main. This PR fixes that issue.

# 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.
-->
This commit is contained in:
Darren Schroeder 2023-10-23 13:22:32 -05:00 committed by GitHub
parent c799f77577
commit ff3a0a0de3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet};
use nu_protocol::{ use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack, StateWorkingSet},
record, Category, Example, IntoPipelineData, PipelineData, PipelineMetadata, Record, record, Category, Example, IntoPipelineData, PipelineData, PipelineMetadata, Record,
ShellError, Signature, Type, Value, ShellError, Signature, Type, Value,
}; };
@ -110,28 +110,36 @@ impl Command for Describe {
)), )),
))), ))),
}, },
// TODO: Uncomment these tests when/if we allow external commands in examples.
/*
Example { Example {
description: "Describe the type of a stream with detailed information", description: "Describe the type of a stream with detailed information",
example: "[1 2 3] | each {|i| $i} | describe -d", example: "[1 2 3] | each {|i| echo $i} | describe -d",
result: Some(Value::test_record(record!( result: None // Give "Running external commands not supported" error
"type" => Value::test_string("stream"), // result: Some(Value::test_record(record!(
"origin" => Value::test_string("nushell"), // "type" => Value::test_string("stream"),
"subtype" => Value::test_string("int"), // "origin" => Value::test_string("nushell"),
))), // "subtype" => Value::test_record(record!(
// "type" => Value::test_string("list"),
// "length" => Value::test_int(3),
// "values" => Value::test_list(vec![
// Value::test_string("int"),
// Value::test_string("int"),
// Value::test_string("int"),
// ])
// ))
// ))),
}, },
Example { Example {
description: "Describe a stream of data, collecting it first", description: "Describe a stream of data, collecting it first",
example: "[1 2 3] | each {|i| $i} | describe", example: "[1 2 3] | each {|i| echo $i} | describe",
result: Some(Value::test_string("list<int> (stream)")), result: None // Give "Running external commands not supported" error
// result: Some(Value::test_string("list<int> (stream)")),
}, },
Example { Example {
description: "Describe the input but do not collect streams", description: "Describe the input but do not collect streams",
example: "[1 2 3] | each {|i| $i} | describe --no-collect", example: "[1 2 3] | each {|i| echo $i} | describe --no-collect",
result: Some(Value::test_string("stream")), result: None // Give "Running external commands not supported" error
// result: Some(Value::test_string("stream")),
}, },
*/
] ]
} }
@ -145,10 +153,8 @@ fn run(
call: &Call, call: &Call,
input: PipelineData, input: PipelineData,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let metadata = input.metadata().clone(); let metadata = input.metadata().clone().map(Box::new);
let head = call.head; let head = call.head;
let no_collect: bool = call.has_flag("no-collect"); let no_collect: bool = call.has_flag("no-collect");
let detailed = call.has_flag("detailed"); let detailed = call.has_flag("detailed");