mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Fix signatures of commands which accept records also (#7582)
# Description Certain commands that operate on tables also work on bare records, but their type sig didn't reflect that. This corrects this. I did not fix certain commands which, I feel, currently give unintended behaviour when given plain records. These are `sort-by` and `uniq-by`. Also corrected the wording of some stuff in headers.rs, and removed a wrong comment in insert.rs. # User-Facing Changes See above. # 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.
This commit is contained in:
@ -14,20 +14,30 @@ impl Command for ToUrl {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("to url")
|
||||
.input_output_types(vec![(Type::Table(vec![]), Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::String),
|
||||
(Type::Table(vec![]), Type::String),
|
||||
])
|
||||
.category(Category::Formats)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Convert table into url-encoded text"
|
||||
"Convert record or table into URL-encoded text"
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Outputs an URL string representing the contents of this table",
|
||||
example: r#"[[foo bar]; ["1" "2"]] | to url"#,
|
||||
result: Some(Value::test_string("foo=1&bar=2")),
|
||||
}]
|
||||
vec![
|
||||
Example {
|
||||
description: "Outputs a URL string representing the contents of this record",
|
||||
example: r#"{ mode:normal userid:31415 } | to url"#,
|
||||
result: Some(Value::test_string("mode=normal&userid=31415")),
|
||||
},
|
||||
Example {
|
||||
description: "Outputs a URL string representing the contents of this 1-row table",
|
||||
example: r#"[[foo bar]; ["1" "2"]] | to url"#,
|
||||
result: Some(Value::test_string("foo=1&bar=2")),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
Reference in New Issue
Block a user