Rename to url command to url build-query (#7702)

# Description

Refactor command: "to url" in: "to url query". Changed usage sentence.
Closes: #7495

# User-Facing Changes

Now we get a query string from a record or table by using command: "to
url query".

```
> help to url query
Convert record or table into query string applying percent-encoding.

Usage:
  > to url query

Flags:
  -h, --help - Display the help message for this command

Signatures:
  <record> | to url query -> <string>
  <table> | to url query -> <string>

Examples:
  Outputs a query string representing the contents of this record
  > { mode:normal userid:31415 } | to url query

  Outputs a query string representing the contents of this 1-row table
  > [[foo bar]; ["1" "2"]] | to url query

  Outputs a query string representing the contents of this record
  > {a:"AT&T", b: "AT T"} | to url query
```

# Tests + Formatting

Added this test:
```
Example {
    description: "Outputs a query string representing the contents of this record",
    example: r#"{a:"AT&T", b: "AT T"} | to url query"#,
    result: Some(Value::test_string("a=AT%26T&b=AT+T")),
},
```
to ensure percent-encoding. 

# After Submitting

If PR is accepted I'll open another PR on documentation to notify
changes on
[this.](https://github.com/nushell/nushell.github.io/blob/main/book/commands/to_url.md)
This commit is contained in:
Vincenzo Carlino
2023-01-15 19:16:29 +01:00
committed by GitHub
parent a909c60f05
commit 92c4097f8d
5 changed files with 24 additions and 15 deletions

View File

@ -355,7 +355,6 @@ pub fn create_default_context() -> EngineState {
Use,
Upsert,
Where,
ToUrl,
ToXml,
ToYaml,
};
@ -437,6 +436,7 @@ pub fn create_default_context() -> EngineState {
Fetch,
Post,
Url,
UrlBuildQuery,
UrlEncode,
UrlParse,
Port,