From 35c84854428f4c2771bb6570cf806e7c09214bbc Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Fri, 28 Apr 2023 09:07:38 +0200 Subject: [PATCH] FEATURE: add `--expand` to `std clip` (#8970) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description i use `std clip` to copy everything from `nushell`. however i have the auto-expand on tables enabled and when i use `clip` on large tables, it does not copy what i see but the collapsed data => i have to edit the line and add `| table --expand` manually, which is a pain to do regularly :scream: in this PR, i just add `--expand` to `std clip` to automatically expand the data before copying it :yum: # User-Facing Changes exploring the `Cargo.toml` of `nushell` with auto-expand, one might see ``` > open Cargo.toml | get package.metadata.binstall.overrides ╭────────────────────────┬───────────────────╮ │ │ ╭─────────┬─────╮ │ │ x86_64-pc-windows-msvc │ │ pkg-fmt │ zip │ │ │ │ ╰─────────┴─────╯ │ ╰────────────────────────┴───────────────────╯ ``` but then ``` open Cargo.toml | get package.metadata.binstall.overrides | clip ``` would only copy ``` ╭────────────────────────┬──────────────────╮ │ x86_64-pc-windows-msvc │ {record 1 field} │ ╰────────────────────────┴──────────────────╯ ``` ... now ``` open Cargo.toml | get package.metadata.binstall.overrides | clip --expand ``` will copy the expanded record :+1: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ``` --- crates/nu-std/lib/mod.nu | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/nu-std/lib/mod.nu b/crates/nu-std/lib/mod.nu index 71d2f96c3f..6e77810f4f 100644 --- a/crates/nu-std/lib/mod.nu +++ b/crates/nu-std/lib/mod.nu @@ -107,8 +107,14 @@ def check-clipboard [ export def clip [ --silent: bool # do not print the content of the clipboard to the standard output --no-notify: bool # do not throw a notification (only on linux) + --expand (-e): bool # auto-expand the data given as input ] { - let input = ($in | table | into string | ansi strip) + let input = ( + $in + | if $expand { table --expand } else { table } + | into string + | ansi strip + ) match $nu.os-info.name { "linux" => {