From e1b598d478b7eb1ddeb228db889e1c0b18b6ce33 Mon Sep 17 00:00:00 2001 From: EmNudge Date: Sun, 24 May 2020 13:10:30 -0400 Subject: [PATCH] added examples and explanation to trim (#1876) * added examples and explanation to trim inserted examples (taken from parse in cookbook) for lists and tables using trim * Move `to-json` to `to json` Co-authored-by: Jonathan Turner --- docs/commands/trim.md | 44 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/commands/trim.md b/docs/commands/trim.md index 5f01a688f7..b748e932f8 100644 --- a/docs/commands/trim.md +++ b/docs/commands/trim.md @@ -9,4 +9,46 @@ Trim leading and following whitespace from text data Hello world > echo " Hello world" | trim Hello world -``` \ No newline at end of file +``` + +Trim can also be passed a list or table of text, for which it will trim each item individually. +It will fail if any element in the list or table is not of type String. +```shell +> open greetings.json | to json +[" hi ", " hello ", " wassup "] +> open greetings.json | trim | to json +["hi", "hello", "wassup"] +``` +```shell +> cargo search shells --limit 10 | lines | parse "{crate_name} = {version} #{description}" +━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ crate_name │ version │ description +───┼────────────────────┼─────────────────────────────┼────────────────────────────────────────────────────────────────────────────────── + 0 │ shells │ "0.2.0" │ Sugar-coating for invoking shell commands directly from Rust. + 1 │ ion-shell │ "0.0.0" │ The Ion Shell + 2 │ shell-words │ "0.1.0" │ Process command line according to parsing rules of UNIX shell + 3 │ nu │ "0.5.0" │ A shell for the GitHub era + 4 │ dotenv-shell │ "1.0.1" │ Launch a new shell (or another program) with your loaded dotenv + 5 │ shell_completion │ "0.0.1" │ Write shell completion scripts in pure Rust + 6 │ shell-hist │ "0.2.0" │ A CLI tool for inspecting shell history + 7 │ tokei │ "10.0.1" │ A utility that allows you to count code, quickly. + 8 │ rash-shell │ "0.1.0" │ A bourne-compatible shell inspired by dash + 9 │ rust_keylock_shell │ "0.10.0" │ Shell access to the rust-keylock. rust-keylock is a password manager with goals + │ │ │ to be Secure, … +━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> cargo search shells --limit 10 | lines | parse "{crate_name} = {version} #{description}" | trim +━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ crate_name │ version │ description +───┼────────────────────┼──────────┼────────────────────────────────────────────────────────────────────────────────── + 0 │ shells │ "0.2.0" │ Sugar-coating for invoking shell commands directly from Rust. + 1 │ ion-shell │ "0.0.0" │ The Ion Shell + 2 │ shell-words │ "0.1.0" │ Process command line according to parsing rules of UNIX shell + 3 │ nu │ "0.5.0" │ A shell for the GitHub era + 4 │ dotenv-shell │ "1.0.1" │ Launch a new shell (or another program) with your loaded dotenv + 5 │ shell_completion │ "0.0.1" │ Write shell completion scripts in pure Rust + 6 │ shell-hist │ "0.2.0" │ A CLI tool for inspecting shell history + 7 │ tokei │ "10.0.1" │ A utility that allows you to count code, quickly. + 8 │ rash-shell │ "0.1.0" │ A bourne-compatible shell inspired by dash + 9 │ rust_keylock_shell │ "0.10.0" │ Shell access to the rust-keylock. rust-keylock is a password manager with goals + │ │ │ to be Secure, … +━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━