nushell/crates
Artemiy 1867bb1a88
Fix incorrect handling of boolean flags for builtin commands (#11492)
# Description
Possible fix of #11456
This PR fixes a bug where builtin commands did not respect the logic of
dynamically passed boolean flags. The reason is
[has_flag](6f59abaf43/crates/nu-protocol/src/ast/call.rs (L204C5-L212C6))
method did not evaluate and take into consideration expression used with
flag.

To address this issue a solution is proposed:
1. `has_flag` method is moved to `CallExt` and new logic to evaluate
expression and check if it is a boolean value is added
2. `has_flag_const` method is added to `CallExt` which is a constant
version of `has_flag`
3. `has_named` method is added to `Call` which is basically the old
logic of `has_flag`
4. All usages of `has_flag` in code are updated, mostly to pass
`engine_state` and `stack` to new `has_flag`. In `run_const` commands it
is replaced with `has_flag_const`. And in a few select places: parser,
`to nuon` and `into string` old logic via `has_named` is used.

# User-Facing Changes
Explicit values of boolean flags are now respected in builtin commands.
Before:

![image](https://github.com/nushell/nushell/assets/17511668/f9fbabb2-3cfd-43f9-ba9e-ece76d80043c)
After:

![image](https://github.com/nushell/nushell/assets/17511668/21867596-2075-437f-9c85-45563ac70083)

Another example:
Before:

![image](https://github.com/nushell/nushell/assets/17511668/efdbc5ca-5227-45a4-ac5b-532cdc2bbf5f)
After:

![image](https://github.com/nushell/nushell/assets/17511668/2907d5c5-aa93-404d-af1c-21cdc3d44646)


# Tests + Formatting
Added test reproducing some variants of original issue.
2024-01-11 17:19:48 +02:00
..
nu-cli Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-cmd-base Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-cmd-dataframe Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-cmd-extra Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-cmd-lang Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-color-config Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-command Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-engine Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-explore Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-glob Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-json Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-lsp Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-parser Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-path Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-plugin Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-pretty-hex Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-protocol Fix incorrect handling of boolean flags for builtin commands (#11492) 2024-01-11 17:19:48 +02:00
nu-std Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-system Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-table Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-term-grid Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-test-support Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu-utils Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_custom_values Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_example Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_formats Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_gstat Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_inc Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13:00
nu_plugin_python remove vectorize_over_list from python plugin (#9905) 2023-08-03 16:46:48 +02:00
nu_plugin_query Bump to dev version 0.89.1 (#11513) 2024-01-11 00:19:21 +13: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.