From 5f2089a15b77fcdfe4c6210191ea13fa4753d22f Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:16:44 +0200 Subject: [PATCH] Add long options for misc and network (#10753) --- crates/nu-command/src/misc/tutor.rs | 2 +- crates/nu-command/src/network/http/delete.rs | 8 ++++---- crates/nu-command/src/network/http/get.rs | 6 +++--- crates/nu-command/src/network/http/head.rs | 5 +++-- crates/nu-command/src/network/http/options.rs | 8 ++++---- crates/nu-command/src/network/http/patch.rs | 8 +++++--- crates/nu-command/src/network/http/post.rs | 6 +++--- crates/nu-command/src/network/http/put.rs | 6 +++--- crates/nu_plugin_query/src/nu/mod.rs | 6 +++--- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/crates/nu-command/src/misc/tutor.rs b/crates/nu-command/src/misc/tutor.rs index 815537a628..d588c24e0e 100644 --- a/crates/nu-command/src/misc/tutor.rs +++ b/crates/nu-command/src/misc/tutor.rs @@ -60,7 +60,7 @@ impl Command for Tutor { }, Example { description: "Search a tutorial by phrase", - example: "tutor -f \"$in\"", + example: "tutor --find \"$in\"", result: None, }, ] diff --git a/crates/nu-command/src/network/http/delete.rs b/crates/nu-command/src/network/http/delete.rs index eb574d1e8a..4515eb416b 100644 --- a/crates/nu-command/src/network/http/delete.rs +++ b/crates/nu-command/src/network/http/delete.rs @@ -115,23 +115,23 @@ impl Command for SubCommand { }, Example { description: "http delete from example.com, with username and password", - example: "http delete -u myuser -p mypass https://www.example.com", + example: "http delete --user myuser --password mypass https://www.example.com", result: None, }, Example { description: "http delete from example.com, with custom header", - example: "http delete -H [my-header-key my-header-value] https://www.example.com", + example: "http delete --headers [my-header-key my-header-value] https://www.example.com", result: None, }, Example { description: "http delete from example.com, with body", - example: "http delete -d 'body' https://www.example.com", + example: "http delete --data 'body' https://www.example.com", result: None, }, Example { description: "http delete from example.com, with JSON body", example: - "http delete -t application/json -d { field: value } https://www.example.com", + "http delete --content-type application/json --data { field: value } https://www.example.com", result: None, }, ] diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index 3bd613abdf..9a5379c4cd 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -110,17 +110,17 @@ impl Command for SubCommand { }, Example { description: "Get content from example.com, with username and password", - example: "http get -u myuser -p mypass https://www.example.com", + example: "http get --user myuser --password mypass https://www.example.com", result: None, }, Example { description: "Get content from example.com, with custom header", - example: "http get -H [my-header-key my-header-value] https://www.example.com", + 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", - example: "http get -H [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", + 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 d6b4a86033..505a17d4e4 100644 --- a/crates/nu-command/src/network/http/head.rs +++ b/crates/nu-command/src/network/http/head.rs @@ -94,12 +94,13 @@ impl Command for SubCommand { }, Example { description: "Get headers from example.com, with username and password", - example: "http head -u myuser -p mypass https://www.example.com", + example: "http head --user myuser --password mypass https://www.example.com", result: None, }, Example { description: "Get headers from example.com, with custom header", - example: "http head -H [my-header-key my-header-value] https://www.example.com", + example: + "http head --headers [my-header-key my-header-value] 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 43035e123a..e65c2b46fe 100644 --- a/crates/nu-command/src/network/http/options.rs +++ b/crates/nu-command/src/network/http/options.rs @@ -98,22 +98,22 @@ impl Command for SubCommand { }, Example { description: "Get options from example.com, with username and password", - example: "http options -u myuser -p mypass https://www.example.com", + example: "http options --user myuser --password mypass https://www.example.com", result: None, }, Example { description: "Get options from example.com, with custom header", - example: "http options -H [my-header-key my-header-value] https://www.example.com", + 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", - example: "http options -H [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] https://www.example.com", + 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, }, Example { description: "Simulate a browser cross-origin preflight request from www.example.com to media.example.com", - example: "http options https://media.example.com/api/ -H [Origin https://www.example.com Access-Control-Request-Headers \"Content-Type, X-Custom-Header\" Access-Control-Request-Method GET]", + example: "http options https://media.example.com/api/ --headers [Origin https://www.example.com Access-Control-Request-Headers \"Content-Type, X-Custom-Header\" Access-Control-Request-Method GET]", result: None, }, ] diff --git a/crates/nu-command/src/network/http/patch.rs b/crates/nu-command/src/network/http/patch.rs index f94d10e8da..8c60eb11d7 100644 --- a/crates/nu-command/src/network/http/patch.rs +++ b/crates/nu-command/src/network/http/patch.rs @@ -111,17 +111,19 @@ impl Command for SubCommand { }, Example { description: "Patch content to example.com, with username and password", - example: "http patch -u myuser -p mypass https://www.example.com 'body'", + example: + "http patch --user myuser --password mypass https://www.example.com 'body'", result: None, }, Example { description: "Patch content to example.com, with custom header", - example: "http patch -H [my-header-key my-header-value] https://www.example.com", + example: + "http patch --headers [my-header-key my-header-value] https://www.example.com", result: None, }, Example { description: "Patch content to example.com, with JSON body", - example: "http patch -t application/json https://www.example.com { field: value }", + example: "http patch --content-type application/json https://www.example.com { field: value }", result: None, }, ] diff --git a/crates/nu-command/src/network/http/post.rs b/crates/nu-command/src/network/http/post.rs index bf0b3a0816..ab69259ddc 100644 --- a/crates/nu-command/src/network/http/post.rs +++ b/crates/nu-command/src/network/http/post.rs @@ -111,17 +111,17 @@ impl Command for SubCommand { }, Example { description: "Post content to example.com, with username and password", - example: "http post -u myuser -p mypass https://www.example.com 'body'", + example: "http post --user myuser --password mypass https://www.example.com 'body'", result: None, }, Example { description: "Post content to example.com, with custom header", - example: "http post -H [my-header-key my-header-value] https://www.example.com", + example: "http post --headers [my-header-key my-header-value] https://www.example.com", result: None, }, Example { description: "Post content to example.com, with JSON body", - example: "http post -t application/json https://www.example.com { field: value }", + example: "http post --content-type application/json https://www.example.com { field: value }", result: None, }, ] diff --git a/crates/nu-command/src/network/http/put.rs b/crates/nu-command/src/network/http/put.rs index 8b49e40aef..da95f61a1e 100644 --- a/crates/nu-command/src/network/http/put.rs +++ b/crates/nu-command/src/network/http/put.rs @@ -111,17 +111,17 @@ impl Command for SubCommand { }, Example { description: "Put content to example.com, with username and password", - example: "http put -u myuser -p mypass https://www.example.com 'body'", + example: "http put --user myuser --password mypass https://www.example.com 'body'", result: None, }, Example { description: "Put content to example.com, with custom header", - example: "http put -H [my-header-key my-header-value] https://www.example.com", + example: "http put --headers [my-header-key my-header-value] https://www.example.com", result: None, }, Example { description: "Put content to example.com, with JSON body", - example: "http put -t application/json https://www.example.com { field: value }", + example: "http put --content-type application/json https://www.example.com { field: value }", result: None, }, ] diff --git a/crates/nu_plugin_query/src/nu/mod.rs b/crates/nu_plugin_query/src/nu/mod.rs index 144d93e923..298a1ad0cc 100644 --- a/crates/nu_plugin_query/src/nu/mod.rs +++ b/crates/nu_plugin_query/src/nu/mod.rs @@ -72,17 +72,17 @@ impl Plugin for Query { pub fn web_examples() -> Vec { vec![PluginExample { - example: "http get https://phoronix.com | query web -q 'header'".into(), + example: "http get https://phoronix.com | query web --query 'header'".into(), description: "Retrieve all `
` elements from phoronix.com website".into(), result: None, }, PluginExample { example: "http get https://en.wikipedia.org/wiki/List_of_cities_in_India_by_population - | query web -t [Rank City 'Population(2011)[3]' 'Population(2001)[3][a]' 'State or union territory']".into(), + | query web --as-table [Rank City 'Population(2011)[3]' 'Population(2001)[3][a]' 'State or union territory']".into(), description: "Retrieve a html table from Wikipedia and parse it into a nushell table using table headers as guides".into(), result: None }, PluginExample { - example: "http get https://www.nushell.sh | query web -q 'h2, h2 + p' | group 2 | each {rotate --ccw tagline description} | flatten".into(), + example: "http get https://www.nushell.sh | query web --query 'h2, h2 + p' | group 2 | each {rotate --ccw tagline description} | flatten".into(), description: "Pass multiple css selectors to extract several elements within single query, group the query results together and rotate them to create a table".into(), result: None, },