From 60e9f469af4f6011b29987e1a88737b1999c00ab Mon Sep 17 00:00:00 2001 From: Tyarel <98483313+Tyarel8@users.noreply.github.com> Date: Thu, 1 May 2025 16:42:53 +0200 Subject: [PATCH] change `http get` header example to use a record (#15674) # Description When first using `http get`, I was confused that all the examples used a list for headers, leading me to believe this was the only way, and it seemed a little weird having records in the language. Then, I found out that you can indeed use record, so I changed the example to show this behavior in a way users can find. There still is another examples that uses a list so there should be no problem there. # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/network/http/delete.rs | 9 +++++++-- crates/nu-command/src/network/http/get.rs | 6 +++--- crates/nu-command/src/network/http/head.rs | 10 ++++++++-- crates/nu-command/src/network/http/options.rs | 6 +++--- crates/nu-command/src/network/http/patch.rs | 10 ++++++++-- crates/nu-command/src/network/http/post.rs | 9 +++++++-- crates/nu-command/src/network/http/put.rs | 9 +++++++-- 7 files changed, 43 insertions(+), 16 deletions(-) diff --git a/crates/nu-command/src/network/http/delete.rs b/crates/nu-command/src/network/http/delete.rs index f46c16b584..97bd681608 100644 --- a/crates/nu-command/src/network/http/delete.rs +++ b/crates/nu-command/src/network/http/delete.rs @@ -117,8 +117,13 @@ impl Command for HttpDelete { result: None, }, Example { - description: "http delete from example.com, with custom header", - example: "http delete --headers [my-header-key my-header-value] https://www.example.com", + description: "http delete from example.com, with custom header using a record", + example: "http delete --headers {my-header-key: my-header-value} https://www.example.com", + result: None, + }, + Example { + description: "http delete from example.com, with custom header using a list", + example: "http delete --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, Example { diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index f317b4b080..ddc04f1f9f 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -115,12 +115,12 @@ impl Command for HttpGet { result: None, }, Example { - description: "Get content from example.com, with custom header", - example: "http get --headers [my-header-key my-header-value] https://www.example.com", + description: "Get content from example.com, with custom header using a record", + example: "http get --headers {my-header-key: my-header-value} https://www.example.com", result: None, }, Example { - description: "Get content from example.com, with custom headers", + description: "Get content from example.com, with custom headers using a list", example: "http get --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, diff --git a/crates/nu-command/src/network/http/head.rs b/crates/nu-command/src/network/http/head.rs index 5298fefda8..be94529420 100644 --- a/crates/nu-command/src/network/http/head.rs +++ b/crates/nu-command/src/network/http/head.rs @@ -97,9 +97,15 @@ impl Command for HttpHead { result: None, }, Example { - description: "Get headers from example.com, with custom header", + description: "Get headers from example.com, with custom header using a record", example: - "http head --headers [my-header-key my-header-value] https://www.example.com", + "http head --headers {my-header-key: my-header-value} https://www.example.com", + result: None, + }, + Example { + description: "Get headers from example.com, with custom header using a list", + example: + "http head --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, ] diff --git a/crates/nu-command/src/network/http/options.rs b/crates/nu-command/src/network/http/options.rs index 75a459cb9b..396faee15a 100644 --- a/crates/nu-command/src/network/http/options.rs +++ b/crates/nu-command/src/network/http/options.rs @@ -96,12 +96,12 @@ impl Command for HttpOptions { result: None, }, Example { - description: "Get options from example.com, with custom header", - example: "http options --headers [my-header-key my-header-value] https://www.example.com", + description: "Get options from example.com, with custom header using a record", + example: "http options --headers {my-header-key: my-header-value} https://www.example.com", result: None, }, Example { - description: "Get options from example.com, with custom headers", + description: "Get options from example.com, with custom headers using a list", example: "http options --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, diff --git a/crates/nu-command/src/network/http/patch.rs b/crates/nu-command/src/network/http/patch.rs index ee8143650a..eb0064e522 100644 --- a/crates/nu-command/src/network/http/patch.rs +++ b/crates/nu-command/src/network/http/patch.rs @@ -114,9 +114,15 @@ impl Command for HttpPatch { result: None, }, Example { - description: "Patch content to example.com, with custom header", + description: "Patch content to example.com, with custom header using a record", example: - "http patch --headers [my-header-key my-header-value] https://www.example.com", + "http patch --headers {my-header-key: my-header-value} https://www.example.com", + result: None, + }, + Example { + description: "Patch content to example.com, with custom header using a list", + example: + "http patch --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, Example { diff --git a/crates/nu-command/src/network/http/post.rs b/crates/nu-command/src/network/http/post.rs index 8c2a3edb9d..41b316c65d 100644 --- a/crates/nu-command/src/network/http/post.rs +++ b/crates/nu-command/src/network/http/post.rs @@ -113,8 +113,13 @@ impl Command for HttpPost { result: None, }, Example { - description: "Post content to example.com, with custom header", - example: "http post --headers [my-header-key my-header-value] https://www.example.com", + description: "Post content to example.com, with custom header using a record", + example: "http post --headers {my-header-key: my-header-value} https://www.example.com", + result: None, + }, + Example { + description: "Post content to example.com, with custom header using a list", + example: "http post --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, Example { diff --git a/crates/nu-command/src/network/http/put.rs b/crates/nu-command/src/network/http/put.rs index 69adaa9aba..53fb975f4a 100644 --- a/crates/nu-command/src/network/http/put.rs +++ b/crates/nu-command/src/network/http/put.rs @@ -113,8 +113,13 @@ impl Command for HttpPut { result: None, }, Example { - description: "Put content to example.com, with custom header", - example: "http put --headers [my-header-key my-header-value] https://www.example.com", + description: "Put content to example.com, with custom header using a record", + example: "http put --headers {my-header-key: my-header-value} https://www.example.com", + result: None, + }, + Example { + description: "Put content to example.com, with custom header using a list", + example: "http put --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", result: None, }, Example {