nushell/crates
Antoine Stevan 79d9a0542f
allow into filesize to take tables as input / output (#9706)
# Description
i have the following command that should give a table of all the mounted
devices with information about their sizes, etc, etc... a glorified
output for the `df -h` command:
```nushell
def disk [] {
    df -h
      | str replace "Mounted on" "Mountpoint"
      | detect columns
      | rename filesystem size used avail used% mountpoint
      | into filesize size used avail
      | upsert used% {|it| 100 * (1 - $it.avail / $it.size)}
}
```

this should work given the first example of `into filesize`
```nushell
  Convert string to filesize in table
  > [[bytes]; ['5'] [3.2] [4] [2kb]] | into filesize bytes
```

## before this PR
it does not even parse
```nushell
Error: nu::parser::input_type_mismatch

  × Command does not support table input.
   ╭─[entry #1:5:1]
 5 │       | rename filesystem size used avail used% mountpoint
 6 │       | into filesize size used avail
   ·         ──────┬──────
   ·               ╰── command doesn't support table input
 7 │       | upsert used% {|it| 100 * (1 - $it.avail / $it.size)}
   ╰────
```

> **Note**
> this was working before the recent input / output type changes

## with this PR
it parses again and gives
```nushell
> disk | where mountpoint == "/" | into record
╭────────────┬───────────────────╮
│ filesystem │ /dev/sda2         │
│ size       │ 217.9 GiB         │
│ used       │ 158.3 GiB         │
│ avail      │ 48.4 GiB          │
│ used%      │ 77.77777777777779 │
│ mountpoint │ /                 │
╰────────────┴───────────────────╯
```

> **Note**
> the two following commands also work now and did not before the PR
> ```nushell
> ls | insert name_size {|it| $it.name | str length} | into filesize
name_size
> ```
> ```nushell
> [[device size]; ["/dev/sda1" 200] ["/dev/loop0" 50]] | into filesize
size
> ```

# User-Facing Changes
`into filesize` works back with tables and this effectively fixes the
doc.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

this PR gives a `result` back to the first table example to make sure it
works fine.

# After Submitting
2023-07-16 08:04:35 -05:00
..
nu_plugin_custom_values Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu_plugin_example Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu_plugin_formats Bump indexmap to 2.0 (#9643) 2023-07-10 10:30:01 +02:00
nu_plugin_gstat Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu_plugin_inc Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu_plugin_python update nu_plugin_python due to signature changes (#8107) 2023-02-18 13:27:24 +00:00
nu_plugin_query Bump scraper from 0.16.0 to 0.17.1 (#9638) 2023-07-10 05:28:36 +00:00
nu-cli add more input_output_types found from breaking scripts (#9683) 2023-07-14 10:58:41 -05:00
nu-cmd-base Bump indexmap to 2.0 (#9643) 2023-07-10 10:30:01 +02:00
nu-cmd-dataframe Apply nightly clippy lints (#9654) 2023-07-12 00:00:31 +02:00
nu-cmd-extra Input output checking (#9680) 2023-07-14 15:20:35 +12:00
nu-cmd-lang add match guards (#9621) 2023-07-16 12:25:12 +12:00
nu-color-config remove let-env, focus on mutating $env (#9574) 2023-07-01 07:57:51 +12:00
nu-command allow into filesize to take tables as input / output (#9706) 2023-07-16 08:04:35 -05:00
nu-engine Change input/output types in help to a table (#9686) 2023-07-15 06:23:21 +12:00
nu-explore nu-explore/ Add handlers for HOME/END keys (#9666) 2023-07-12 14:13:35 -05:00
nu-glob Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu-json Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu-parser add match guards (#9621) 2023-07-16 12:25:12 +12:00
nu-path Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu-plugin Improve type hovers (#9515) 2023-06-29 05:19:48 +12:00
nu-pretty-hex Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu-protocol add match guards (#9621) 2023-07-16 12:25:12 +12:00
nu-std fix the std test commands calls in dev documents (#9535) 2023-07-12 18:26:47 +02:00
nu-system Use is-terminal crate for now (#9670) 2023-07-12 18:15:54 +02:00
nu-table Fix #9548 (#9552) 2023-06-28 17:52:04 -05:00
nu-term-grid Bump to 0.82.1 dev version (#9543) 2023-06-27 21:33:53 +02:00
nu-test-support Document fn pipeline() used with nu! tests (#9609) 2023-07-05 13:19:54 +02:00
nu-utils Move to using a safer shell integration default setting (#9600) 2023-07-04 06:26:49 +12:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.