mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
7ac5a01e2f
# Description looking at the [Wax documentation about `wax::Walk.not`](https://docs.rs/wax/latest/wax/struct.Walk.html#examples), especially > therefore does not read directory trees from the file system when a directory matches an [exhaustive glob expression](https://docs.rs/wax/latest/wax/trait.Pattern.html#tymethod.is_exhaustive) > **Important** > in the following of this PR description, i talk about *pruning* and a `--prune` option, but this has been changed to *exclusion* and `--exclude` after a discussion with @fdncred. this looks like a *pruning* operation to me, right? 😮 i wanted to make the `glob` option `--not` clearer about that, because > -n, --not <List(String)> - Patterns to exclude from the results from `help glob` is not very explicit about whether the search is pruned when entering a directory matching a pattern in `--not` or just removing it from the output 😕 ## changelog this PR proposes to rename the `glob --not` option to `glob --prune` and make it's documentation more explicit 😋 ## benchmarking to support the *pruning* behaviour put forward above, i've run a benchmark 1. define two closures to compare the behaviour between removing patterns manually or using `--not` ```nushell let where = { [.*/\.local/.*, .*/documents/.*, .*/\.config/.*] | reduce --fold (glob **) {|pat, acc| $acc | where $it !~ $pat} | length } ``` ```nushell let not = { glob ** --not [**/.local/**, **/documents/**, **/.config/**] | length } ``` 2. run the two to make sure they give similar results ```nushell > do $where 33424 ``` ```nushell > do $not 33420 ``` 👌 3. measure the performance ```nushell use std bench ``` ```nushell > bench --verbose --pretty --rounds 25 $not 44ms 52µs 285ns +/- 977µs 571ns ``` ```nushell > bench --verbose --pretty --rounds 5 $where 1sec 250ms 187µs 99ns +/- 8ms 538µs 57ns ``` 👉 we can see that the results are (almost) the same but `--not` is much faster, looks like pruning 😋 # User-Facing Changes - `--not` will give a warning message but still work - `--prune` will work just as `--not` without warning and with a more explicit doc - `--prune` and `--not` at the same time will give an error # Tests + Formatting this PR fixes the examples of `glob` using the `--not` option. # After Submitting prepare the removal PR and mention in release notes. |
||
---|---|---|
.. | ||
nu-cli | ||
nu-cmd-base | ||
nu-cmd-dataframe | ||
nu-cmd-extra | ||
nu-cmd-lang | ||
nu-color-config | ||
nu-command | ||
nu-engine | ||
nu-explore | ||
nu-glob | ||
nu-json | ||
nu-parser | ||
nu-path | ||
nu-plugin | ||
nu-pretty-hex | ||
nu-protocol | ||
nu-std | ||
nu-system | ||
nu-table | ||
nu-term-grid | ||
nu-test-support | ||
nu-utils | ||
nu_plugin_custom_values | ||
nu_plugin_example | ||
nu_plugin_formats | ||
nu_plugin_gstat | ||
nu_plugin_inc | ||
nu_plugin_python | ||
nu_plugin_query | ||
README.md |
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.