Commit Graph

5512 Commits

Author SHA1 Message Date
Stefan Holderbach
c00a05a762
Bump version to 0.92.1 (#12380) 2024-04-04 16:18:54 +02:00
Devyn Cairns
51aa66fef7
Fix #12391: mkdir uses process startup directory instead of current script directory (#12394)
# Description

This fixes #12391.

nushell/nushell@87c5f6e455 accidentally introduced a bug where the path
was not being properly
expanded according to the cwd. This makes both 'touch' and 'mkdir' use
globs just like the rest of
the commands to preserve tilde behavior while still expanding the paths
properly.

This doesn't actually expand the globs. Should it?

# User-Facing Changes

- Restore behavior of `mkdir`, `touch`
- Help text now says they can take globs, but they won't actually expand
them, maybe this should be changed

# Tests + Formatting

Regression tests added.


# After Submitting

This is severe enough and should be included in the point release.
2024-04-04 14:23:10 +02:00
Deep Panchal
25b90744b7
fix simple typo in commandline_.rs (#12387)
Fix typo in crates/nu-cli/src/commands/commandline/commandline_.rs
`Replaceing` -> `Replacing`
2024-04-04 09:59:52 +02:00
Stefan Holderbach
e810995cf8
Bump crate-ci/typos and fix typos (#12381)
Supersede #12376
2024-04-04 09:59:21 +02:00
pwygab
f0a073b397
prevent parser from parsing variables as units (#12378)
# Description

Resolves #11274.

```
~/CodingProjects/nushell> let day = 2; echo 0..<$day
╭───┬───╮
│ 0 │ 0 │
│ 1 │ 1 │
╰───┴───╯
~/CodingProjects/nushell> let kb = "jan"; echo 0..$kb 
Error: nu:🐚:type_mismatch

  × Type mismatch during operation.
   ╭─[entry #1:1:22]
 1 │ let kb = "jan"; echo 0..$kb
   ·                      ┬─┬─┬─
   ·                      │ │ ╰── string
   ·                      │ ╰── type mismatch for operator
   ·                      ╰── int
   ╰────
```


# Tests + Formatting

Relevant test added 🆙 

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2024-04-04 09:55:14 +02:00
Ian Manske
cd00a489af
Fix hooks on 0.92.0 (#12383)
# Description
Fixes #12382, where overlay changes from hooks were not preserved into
the global state. This was due to creating child stacks for hooks, when
the global stack should have been used instead.
2024-04-04 09:25:54 +02:00
Devyn Cairns
cbf7feef22
Make drop notification timing for plugin custom values more consistent (#12341)
# Description
This keeps plugin custom values that have requested drop notification
around during the lifetime of a plugin call / stream by sending them to
a channel that gets persisted during the lifetime of the call.

Before this change, it was very likely that the drop notification would
be sent before the plugin ever had a chance to handle the value it
received.

Tests have been added to make sure this works - see the `custom_values`
plugin.

cc @ayax79 

# User-Facing Changes
This is basically just a bugfix, just a slightly big one.

However, I did add an `as_mut_any()` function for custom values, to
avoid having to clone them. This is a breaking change.
2024-04-04 09:13:25 +02:00
Stefan Holderbach
a6afc89338
Make default config conservative about clipboard (#12385)
Some platforms don't support the `system-clipboard` feature, notably
termux on android.
The default config currently contained references to `reedline` events
that are only available with the feature enabled (#12179). This thus
broke the out of the box config for those users.

For now be more defensive about this and only enable default events. Add
the alternative as commented out code you can quickly enable.

## Tested with:

```
cargo run --no-default-features --features default-no-clipboard -- --config crates/nu-utils/src/sample_config/default_config.nu
```
2024-04-04 09:10:41 +02:00
Darren Schroeder
c7b9183e47
bump python plugin nushell version (#12367)
# Description

This PR bumps the python plugin to keep it in sync with the nushell
version.
2024-04-03 15:33:37 +02:00
Jakub Žádník
b6c537d782
Add missing crate description to nu-plugin-test-support (#12368) 2024-04-03 15:33:18 +02:00
Stefan Holderbach
c3428b891a
Bump version for 0.92.0 release (#12349)
- [x] `cargo hack` feature flag compatibility run
- [x] reedline released and pinned
- [x] `nu-plugin-test-support` added to release script
- [x] dependency tree checked
- [x] release notes
2024-04-02 20:50:26 +03:00
Ian Manske
aaefc5e110
mkdir umask fix (#12354)
# Description
Fixes how the directory permissions are calculated in `mkdir`. Instead
of subtraction, the umask is actually used as a mask via negation
followed by bitwise and with the default mode. This matches how [uucore
calculates](cac7155fba/src/uu/mkdir/src/mkdir.rs (L61))
the mode.
2024-04-01 20:14:13 +00:00
Stefan Holderbach
0cf7de598b
Refactor Record to use a single backing Vec (#12326)
# Description
This shrinks `Record`'s size in half and and allows you to include it in
`Value` without growing the size.

Changing the `Record` internals may have slightly different performance
characteristics as the cache locality changes on lookups (if you
directly need the value, it should be closer, but in other cases may
blow up the cache line budget)

Also different perf characteristics on creation expected. 
`Record::from_raw_cols_vals` now probably worse.

## Benchmarking

Comparison with the main branch (boxed Record) revealed no significant
change to the creation but an improvement when accessing larger N.
The fact that this was more pronounced for nested access (still cloning
before nushell/nushell#12325) leads to the conclusion that this may
still be dominated by the smaller clone necessary for a 24-byte `Record`
over the previous 48 bytes.

# User-Facing Changes

Reduced memory usage
2024-03-31 00:47:17 +01:00
Stefan Holderbach
3b8258ae57
Remove ambiguous into bits impl for date (#12313)
# Description
Currently `into bits` will try to coerce a `date`/`Value::Date` into a
string with a locale/timezone specific behavior (See #12268).

To resolve the ambiguity, remove the support for `date` entirely.


# User-Facing Changes
`date now | into bits` will now fail.

Instead you can use `... | format date '%c' | into bits` or any more
specific explicit choices to achieve the same behavior.

As `into bits` has minimal uses (and only pulled out of `extra` with
#12140), this doesn't warrant a deprecation.
2024-03-31 00:46:11 +01:00
pwygab
9444020f26
Make autocd return exit code 0 (#12337)
# Description
resolves #11159.

```
~/CodingProjects/nushell> ^false                               
~/CodingProjects/nushell> $env.LAST_EXIT_CODE                         
1
~/CodingProjects/nushell> ^false                                  
~/CodingProjects/nushell> ./crates/          
~/CodingProjects/nushell/crates> $env.LAST_EXIT_CODE
0                                              
```

# User-Facing Changes

autocd now sets exit code to 0.
2024-03-30 15:09:34 +01:00
Ian Manske
251599c507
Use safe nix API instead of libc (#12315)
# Description
Where possible, this PR replaces usages of raw `libc` bindings to
instead use safe interfaces from the `nix` crate. Where not possible,
the `libc` version reexported through `nix` was used instead of having a
separate `libc` dependency.
2024-03-30 14:49:54 +01:00
Devyn Cairns
714a0ccd24
Remove serde derive for ShellError, replace via LabeledError (#12319)
# Description

This changes the interface for plugins to always represent errors as
`LabeledError`s. This is good for altlang plugins, as it would suck for
them to have to implement and track `ShellError`. We save a lot of
generated code from the `ShellError` serde impl too, so `nu` and plugins
get to have a smaller binary size.

Reduces the release binary size by 1.2 MiB on my build configuration.

# User-Facing Changes

- Changes plugin protocol. `ShellError` no longer serialized.
- `ShellError` serialize output is different
- `ShellError` no longer deserializes to exactly the same value as
serialized

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

- [ ] Document in plugin protocol reference
2024-03-30 14:21:40 +01:00
Stefan Holderbach
cc39069e13
Reuse existing small allocations if possible (#12335)
Those allocations are all small and insignificant in the grand scheme of
things and the optimizer may be able to resolve some of those but better
to be nice anyways.

Primarily inspired by the new
[`clippy::assigning_clones`](https://rust-lang.github.io/rust-clippy/master/index.html#/assigning_clones)

- **Avoid reallocs with `clone_from` in `nu-parser`**
- **Avoid realloc on assignment in `Stack`**
- **Fix `clippy::assigning_clones` in `nu-cli`**
- **Reuse allocations in `nu-explore` if possible**
2024-03-30 14:04:11 +01:00
Stefan Holderbach
ce581a80a6
Elide clone in V::follow_cell_path for record (#12325)
# Description
This clone is not necessary and tanks the performance of deep nested
access.
As soon as we found the value, we know we discard the old value, so can
`std::mem::take` the inner (`impl Default for Value` to the rescue)

We may be able to further optimize this but not having to clone the
value is vital.
2024-03-30 14:03:31 +01:00
Stefan Holderbach
e889679d42
Use nightly clippy to kill dead code/fix style (#12334)
- **Remove duplicated imports**
- **Remove unused field in `CompletionOptions`**
- **Remove unused struct in `nu-table`**
- **Clarify generic bounds**
- **Simplify a subtrait bound for `ExactSizeIterator`**
- **Use `unwrap_or_default`**
- **Use `Option` directly instead of empty string**
- **Elide unneeded clone in `to html`**
2024-03-30 09:17:28 +08:00
Wind
ff2aba7ae3
detect columns: intruduce a --guess flag, remove --legacy (#12333)
# Description
This pr is addressing feedback from
https://github.com/nushell/nushell/pull/12277#issuecomment-2027246752

Currently I think it's fine to replace `--legacy` flag with `--guess`
one. Only use `guess_width` algorithm if `--guess` is provided.

# User-Facing Changes
So it won't be a breaking change to previous version.
2024-03-29 19:59:57 -05:00
Skyler Hawthorne
cf923fc44c
into sqlite: Fix insertion of null values (#12328)
# Description

In #10232, the allowed input types were changed to be stricter, only
allowing records with types that can easily map onto sqlite equivalents.
Unfortunately, null was left out of the accepted input types, which
makes inserting rows with null values impossible.

This change fixes that by accepting null values as input.

One caveat of this is that when the command is creating a new table, it
uses the first row to infer an appropriate sqlite schema. If the first
row contains a null value, then it is impossible to tell which type this
column is supposed to have.

Throwing a hard error seems undesirable from a UX perspective, but
guessing can lead to a potentially useless database if we guess wrong.

So as a compromise, for null columns, we will assume the sqlite type is
TEXT and print a warning so the user knows. For the time being, if users
can't avoid a first row with null values, but also wants the right
schema, they are advised to create their table before running `into
sqlite`.

A future PR can add the ability to explicitly specify a schema.

Fixes #12225

# Tests + Formatting

* Tests added to cover expected behavior around insertion of null values
2024-03-29 06:41:16 -05:00
Devyn Cairns
3857e368ff
Fix build of nu-protocol without plugin feature enabled (#12323)
# Description

I broke this, I think in #12279, because I forgot a `#[cfg(plugin)]`
2024-03-28 22:39:57 +01:00
pwygab
04531357b4
Exposed the recursion limit value as a config option (#12308)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

Closes #12253.

Exposes the option as "recursion_limit" under config.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

The config file now has a new option!

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

Nothing else...? Do let me know if there's something I've missed!
2024-03-28 15:40:45 -05:00
Ian Manske
8e763a2fd6
Fix file redirection for externals streams (#12321)
# Description
Fixes `open --raw file o> out.txt` and other instances where
`PipelineData::ExternalStream` is created from sources that are not
external commands.
2024-03-28 20:22:54 +00:00
Ian Manske
442faa5576
Make Record.cols private (#12317)
# Description
Makes the `cols` field in `Record` private and fixes the implementation
of `rename` to account for this change.
2024-03-28 20:18:43 +00:00
Darren Schroeder
e97368433b
add a few more logging statements for debugging startup (#12316)
# Description

This PR adds a few more `trace!()` and `perf()` statements that allowed
a deeper understanding of the nushell startup process when used with `nu
-n --no-std-lib --log-level trace`.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-03-28 11:27:12 -05:00
Stefan Holderbach
910e3b52a7
Avoid uses of Record internals again (#12312)
# Description
Again avoid uses of the `Record` internals, so we are free to change the
data layout

- **Don't use internals of `Record` in `into sqlite`**
- **Don't use internals of `Record` in `to xml`**

Remaining: `rename`

# User-Facing Changes
None
2024-03-28 11:36:12 +01:00
Darren Schroeder
968926a327
keep sqlparser at 39 until polars is upgraded (#12311)
# Description

This PR reverts sqlparser to 0.39.0. It should stay here until we can
get polars updated so that we don't have to have two versions of
sqlparser.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-03-27 19:26:49 -05:00
Stefan Holderbach
b19da158d5
Rename Value::CustomValue to Value::Custom (#12309)
# Description
The second `Value` is redundant and will consume five extra bytes on
each transmission of a custom value to/from a plugin.

# User-Facing Changes
This is a breaking change to the plugin protocol.

The [example in the protocol
reference](https://www.nushell.sh/contributor-book/plugin_protocol_reference.html#value)
becomes

```json
{
  "Custom": {
    "val": {
      "type": "PluginCustomValue",
      "name": "database",
      "data": [36, 190, 127, 40, 12, 3, 46, 83],
      "notify_on_drop": true
    },
    "span": {
      "start": 320,
      "end": 340
    }
  }
}
```

instead of 

```json
{
  "CustomValue": {
    ...
  }
}
```


# After Submitting
Update plugin protocol reference
2024-03-27 22:10:56 +01:00
Stefan Holderbach
dfbbacfdf8
Deduplicate nix dependency versions (#12307)
# Description
Now we only use `nix 0.28.0`

Achieved by
- updating `ctrlc` to `3.4.4`
- updating `wl-clipboard-rs` to `0.8.1`
- update our own dependency on `nix` from `0.27` to `0.28`
  - required fixing uses of `nix::unistd::{tcgetpgrp,tcsetpgrp}`
  - now requires an I/O safe file descriptor
  - fake one pointing to `libc::STDIN_FILENO` (we were only accessing
`0` previously, dito for fish)


# User-Facing Changes
Better compile times and less to download as source dependencies
2024-03-27 16:43:37 +01:00
Auca Coyan
bf8de9d1ea
♻️ rework some help strings (#12306)
# Description

I changed some help outputs:


![image](https://github.com/nushell/nushell/assets/30557287/d25f0fbe-ffc3-43b3-93cf-b1793d2351b6)


![image](https://github.com/nushell/nushell/assets/30557287/acb5581c-8959-4916-8a55-d3ed6a2e1dcf)

I also checked with `rg` the commands deprecated in #9840 and found a
help or a comment here and there.

# User-Facing Changes

same of above

# Tests + Formatting
2024-03-27 08:41:02 -05:00
Devyn Cairns
01d30a416b
Change PluginCommand API to be more like Command (#12279)
# Description

This is something that was discussed in the core team meeting last
Wednesday. @ayax79 is building `nu-plugin-polars` with all of the
dataframe commands into a plugin, and there are a lot of them, so it
would help to make the API more similar. At the same time, I think the
`Command` API is just better anyway. I don't think the difference is
justified, and the types for core commands have the benefit of requiring
less `.into()` because they often don't own their data

- Broke `signature()` up into `name()`, `usage()`, `extra_usage()`,
`search_terms()`, `examples()`
- `signature()` returns `nu_protocol::Signature`
- `examples()` returns `Vec<nu_protocol::Example>`
- `PluginSignature` and `PluginExample` no longer need to be used by
plugin developers

# User-Facing Changes
Breaking API for plugins yet again 😄
2024-03-27 11:59:57 +01:00
dependabot[bot]
03b5e9d853
Bump sqlparser from 0.43.1 to 0.44.0 (#12302)
Bumps [sqlparser](https://github.com/sqlparser-rs/sqlparser-rs) from
0.43.1 to 0.44.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/sqlparser-rs/sqlparser-rs/blob/main/CHANGELOG.md">sqlparser's
changelog</a>.</em></p>
<blockquote>
<h2>[0.44.0] 2024-03-02</h2>
<h3>Added</h3>
<ul>
<li>Support EXPLAIN / DESCR / DESCRIBE [FORMATTED | EXTENDED] (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1156">#1156</a>)
- Thanks <a
href="https://github.com/jonathanlehtoalamb"><code>@​jonathanlehtoalamb</code></a></li>
<li>Support ALTER TABLE ... SET LOCATION (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1154">#1154</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support <code>ROW FORMAT DELIMITED</code> in Hive (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1155">#1155</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support <code>SERDEPROPERTIES</code> for <code>CREATE TABLE</code>
with Hive (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1152">#1152</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support <code>EXECUTE ... USING</code> for Postgres (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1153">#1153</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support Postgres style <code>CREATE FUNCTION</code> in
GenericDialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1159">#1159</a>)
- Thanks <a
href="https://github.com/alamb"><code>@​alamb</code></a></li>
<li>Support <code>SET TBLPROPERTIES</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1151">#1151</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support <code>UNLOAD</code> statement (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1150">#1150</a>)
- Thanks <a
href="https://github.com/jonathanlehto"><code>@​jonathanlehto</code></a></li>
<li>Support <code>MATERIALIZED CTEs</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1148">#1148</a>)
- Thanks <a
href="https://github.com/ReppCodes"><code>@​ReppCodes</code></a></li>
<li>Support <code>DECLARE</code> syntax for snowflake and bigquery (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1122">#1122</a>)
- Thanks <a
href="https://github.com/iffyio"><code>@​iffyio</code></a></li>
<li>Support <code>SELECT AS VALUE</code> and <code>SELECT AS
STRUCT</code> for BigQuery (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1135">#1135</a>)
- Thanks <a
href="https://github.com/lustefaniak"><code>@​lustefaniak</code></a></li>
<li>Support <code>(+)</code> outer join syntax (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1145">#1145</a>)
- Thanks <a
href="https://github.com/jmhain"><code>@​jmhain</code></a></li>
<li>Support <code>INSERT INTO ... SELECT ... RETURNING</code>(<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1132">#1132</a>)
- Thanks <a
href="https://github.com/lovasoa"><code>@​lovasoa</code></a></li>
<li>Support DuckDB <code>INSTALL</code> and <code>LOAD</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1127">#1127</a>)
- Thanks <a
href="https://github.com/universalmind303"><code>@​universalmind303</code></a></li>
<li>Support <code>=</code> operator in function args (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1128">#1128</a>)
- Thanks <a
href="https://github.com/universalmind303"><code>@​universalmind303</code></a></li>
<li>Support <code>CREATE VIEW IF NOT EXISTS</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1118">#1118</a>)
- Thanks <a href="https://github.com/7phs"><code>@​7phs</code></a></li>
<li>Support <code>UPDATE FROM</code> for SQLite (further to <a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/694">#694</a>)
(<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1117">#1117</a>)
- Thanks <a
href="https://github.com/ggaughan"><code>@​ggaughan</code></a></li>
<li>Support optional <code>DELETE FROM</code> statement (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1120">#1120</a>)
- Thanks <a
href="https://github.com/iffyio"><code>@​iffyio</code></a></li>
<li>Support MySQL <code>SHOW STATUS</code> statement (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1119">#1119</a>)
- Thanks invm</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Clean up nightly clippy lints (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1158">#1158</a>)
- Thanks <a
href="https://github.com/alamb"><code>@​alamb</code></a></li>
<li>Handle escape, unicode, and hex in
tokenize_escaped_single_quoted_string (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1146">#1146</a>)
- Thanks <a
href="https://github.com/JasonLi-cn"><code>@​JasonLi-cn</code></a></li>
<li>Fix panic while parsing <code>REPLACE</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1140">#1140</a>)
- THanks <a
href="https://github.com/jjbayer"><code>@​jjbayer</code></a></li>
<li>Fix clippy warning from rust 1.76 (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1130">#1130</a>)
- Thanks <a
href="https://github.com/alamb"><code>@​alamb</code></a></li>
<li>Fix release instructions (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1115">#1115</a>)
- Thanks <a
href="https://github.com/alamb"><code>@​alamb</code></a></li>
</ul>
<h3>Changed</h3>
<ul>
<li>Add <code>parse_keyword_with_tokens</code> for paring keyword and
tokens combination (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1141">#1141</a>)
- Thanks <a
href="https://github.com/viirya"><code>@​viirya</code></a></li>
<li>Add ParadeDB to list of known users (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1142">#1142</a>)
- Thanks <a
href="https://github.com/philippemnoel"><code>@​philippemnoel</code></a></li>
<li>Accept JSON_TABLE both as an unquoted table name and a table-valued
function (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1134">#1134</a>)
- Thanks <a
href="https://github.com/lovasoa"><code>@​lovasoa</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="5da66adda9"><code>5da66ad</code></a>
chore: Release sqlparser version 0.44.0</li>
<li><a
href="1af1a6e87a"><code>1af1a6e</code></a>
Version 0.44.0 CHANGELOG (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1161">#1161</a>)</li>
<li><a
href="ef4668075b"><code>ef46680</code></a>
Support <code>EXPLAIN</code> / <code>DESCR</code> /
<code>DESCRIBE</code> <code>[FORMATTED | EXTENDED]</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1156">#1156</a>)</li>
<li><a
href="991dbab755"><code>991dbab</code></a>
Support <code>ALTER TABLE ... SET LOCATION</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1154">#1154</a>)</li>
<li><a
href="6f090e5547"><code>6f090e5</code></a>
adding delimited (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1155">#1155</a>)</li>
<li><a
href="fb7d4d40cc"><code>fb7d4d4</code></a>
Support <code>serdeproperties</code> for CREATE TABLE with HIVE (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1152">#1152</a>)</li>
<li><a
href="68b52a4ad6"><code>68b52a4</code></a>
Support <code>EXECUTE ... USING</code> for Postgres (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1153">#1153</a>)</li>
<li><a
href="9db9d22480"><code>9db9d22</code></a>
Support postgres style <code>CREATE FUNCTION</code> in
<code>GenericDialect</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1159">#1159</a>)</li>
<li><a
href="a511c47bd0"><code>a511c47</code></a>
set_tblproperties (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1151">#1151</a>)</li>
<li><a
href="10cc54e10e"><code>10cc54e</code></a>
Clean up nightly clippy lints (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/1158">#1158</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/sqlparser-rs/sqlparser-rs/compare/v0.43.1...v0.44.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sqlparser&package-manager=cargo&previous-version=0.43.1&new-version=0.44.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-27 14:44:43 +08:00
dependabot[bot]
6542f23ad1
Bump ical from 0.10.0 to 0.11.0 (#12303)
Bumps [ical](https://github.com/Peltoche/ical-rs) from 0.10.0 to 0.11.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/Peltoche/ical-rs/releases">ical's
releases</a>.</em></p>
<blockquote>
<h2>v0.11.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update the version inside the readme by <a
href="https://github.com/Peltoche"><code>@​Peltoche</code></a> in <a
href="https://redirect.github.com/Peltoche/ical-rs/pull/58">Peltoche/ical-rs#58</a></li>
<li>Fix <a
href="https://redirect.github.com/Peltoche/ical-rs/issues/62">#62</a> by
<a href="https://github.com/ddnomad"><code>@​ddnomad</code></a> in <a
href="https://redirect.github.com/Peltoche/ical-rs/pull/63">Peltoche/ical-rs#63</a></li>
<li>replaced split_line with a multibyte aware version by <a
href="https://github.com/ronnybremer"><code>@​ronnybremer</code></a> in
<a
href="https://redirect.github.com/Peltoche/ical-rs/pull/61">Peltoche/ical-rs#61</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/ddnomad"><code>@​ddnomad</code></a> made
their first contribution in <a
href="https://redirect.github.com/Peltoche/ical-rs/pull/63">Peltoche/ical-rs#63</a></li>
<li><a
href="https://github.com/ronnybremer"><code>@​ronnybremer</code></a>
made their first contribution in <a
href="https://redirect.github.com/Peltoche/ical-rs/pull/61">Peltoche/ical-rs#61</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/Peltoche/ical-rs/compare/v0.10.0...v0.11.0">https://github.com/Peltoche/ical-rs/compare/v0.10.0...v0.11.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="c2f6bb3be9"><code>c2f6bb3</code></a>
chore: Release ical version 0.11.0</li>
<li><a
href="e435769c7b"><code>e435769</code></a>
final fix to test for new split_line</li>
<li><a
href="1db49580e1"><code>1db4958</code></a>
fixed incorrect test for new split_line</li>
<li><a
href="248227b08d"><code>248227b</code></a>
added test case with multibyte characters for split_line</li>
<li><a
href="ba696e5c02"><code>ba696e5</code></a>
take 75 chars of the first line and 74 chars of subsequent lines</li>
<li><a
href="28ffa72bb1"><code>28ffa72</code></a>
replaced split_line with a multibyte aware version</li>
<li><a
href="a10a15d571"><code>a10a15d</code></a>
Fix <a
href="https://redirect.github.com/Peltoche/ical-rs/issues/62">#62</a></li>
<li><a
href="7f93147560"><code>7f93147</code></a>
Update the version inside the readme</li>
<li>See full diff in <a
href="https://github.com/Peltoche/ical-rs/compare/v0.10.0...v0.11.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ical&package-manager=cargo&previous-version=0.10.0&new-version=0.11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-27 14:44:33 +08:00
Ian Manske
c747ec75c9
Add command_prelude module (#12291)
# Description
When implementing a `Command`, one must also import all the types
present in the function signatures for `Command`. This makes it so that
we often import the same set of types in each command implementation
file. E.g., something like this:
```rust
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
    record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
    ShellError, Signature, Span, Type, Value,
};
```

This PR adds the `nu_engine::command_prelude` module which contains the
necessary and commonly used types to implement a `Command`:
```rust
// command_prelude.rs
pub use crate::CallExt;
pub use nu_protocol::{
    ast::{Call, CellPath},
    engine::{Command, EngineState, Stack},
    record, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, IntoSpanned,
    PipelineData, Record, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
};
```

This should reduce the boilerplate needed to implement a command and
also gives us a place to track the breadth of the `Command` API. I tried
to be conservative with what went into the prelude modules, since it
might be hard/annoying to remove items from the prelude in the future.
Let me know if something should be included or excluded.
2024-03-26 21:17:30 +00:00
Ian Manske
b752fdb0dc
Always pretty print binary values in table (#12294)
# Description
Binary values passed to `table` may or may not be pretty formatted based
on the output destination. This leads to weird behavior as documented in
#12287. This PR changes `table` to always pretty print binary values.
However, binary values passed to external commands will not be formatted
(this is the existing behavior).

# User-Facing Changes
This is a breaking change. E.g.:
```nushell
0x[8989] | table | cat -
```
used to print raw bytes, but it will now print the pretty formatted
bytes.

# After Submitting
Add to 0.92.0 release notes and update documentation.
2024-03-26 13:22:34 -05:00
Stefan Holderbach
592dc4bbfa
Fix return in filter closure eval (#12292)
# Description
Closes https://github.com/nushell/nushell/issues/12257

This was down to the use of `eval_block` instead of
`eval_block_with_early_return`. We may want to reconsider how we
differentiate between this behavior. We currently need to check all the
remaining commands that can invoke a closure block, if they properly
handle `ShellError::Return` as a passing of a `Value`

- **Add test for `return` in `filter` closure**
- **Fix use of `return` in `filter` closure**

# User-Facing Changes
You can now return a value from a `filter` closure


# Tests + Formatting
Regression test
2024-03-26 17:50:36 +01:00
Filip Andersson
b70766e6f5
Boxes record for smaller Value enum. (#12252)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Boxes `Record` inside `Value` to reduce memory usage, `Value` goes from
`72` -> `56` bytes after this change.
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-03-26 17:17:44 +02:00
Stefan Holderbach
24d2c8dd8e
Follow API guidelines for public types (#12283)
# Description
Follow the [API guideline naming
conventions](https://rust-lang.github.io/api-guidelines/naming.html)
also for our externally exposed types

(See
[`clippy::wrong_self_convention`](https://rust-lang.github.io/rust-clippy/master/index.html#/wrong_self_convention)
with [`avoid-breaking-exported-api =
false`](https://doc.rust-lang.org/clippy/lint_configuration.html#avoid-breaking-exported-api)
)

Also be a good citizen around doccomments

- **Fix `Unit::to_value` to `Unit::build_value`**
- **Fix `PipelineData::is_external_failed` to `check_external_failed`**
- **Fix doccomment on `check_external_failed`**
- **Fix `Value::into_config` naming to `parse_as_config`**
- **Document `Value::parse_as_config`**

# Plugin-Author-Facing Changes
See renames above
2024-03-26 12:12:25 +01:00
Stefan Holderbach
e8bcfbaed1
Remove dead impl PluginEncoder for EncodingType (#12284)
Detected due to `clippy::wrong_self_convention` for `to_str`

# Breaking change to plugin authors

seems to be implementation detail
2024-03-26 12:11:49 +01:00
Wind
a15462fd00
Change default algorithm in detect columns (#12277)
# Description
@fdncred found another histogram based algorithm to detect columns, and
rewrite it in rust: https://github.com/fdncred/guess-width

I have tested it manually, and it works good with `df`, `docker ps`,
`^ps`. This pr is going to use the algorithm in `detect columns`

Fix: #4183

The pitfall of new algorithm:
1. it may not works well if there isn't too much rows of input
2. it may not works well if the length of value is less than the header
to value, e.g:
```
c1 c2 c3 c4 c5
a b c d e
g h i j k
g a a q d
a v c q q | detect columns
```
In this case, users might need to use ~~`--old`~~ `--legacy` to make it
works well.

# User-Facing Changes
User might need to add ~~`--old`~~ `--legacy` to scripts if they find
`detect columns` in their scripts broken.

# Tests + Formatting
Done

# After Submitting
NaN
2024-03-26 13:57:55 +08:00
Devyn Cairns
2ae4408ced
Add example tests (nu-plugin-test-support) for plugins in repo (#12281)
# Description

Uses the new `nu-plugin-test-support` crate to test the examples of
commands provided by plugins in the repo.

Also fixed some of the examples to pass.

# User-Facing Changes

- Examples that are more guaranteed to work

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
2024-03-25 21:20:35 -05:00
Devyn Cairns
efe1c99a3b
Fix #12280: replace difference crate with similar (#12282)
Fixes #12280.

# Description

This removes the dependency on the `difference` crate, which is
unmaintained, for `nu-plugin-test-support`. The `similar` crate
(Apache-2.0) is used instead, which is a bit larger and more complex,
but still suitable for a dev dep for tests. Also switched to use
`crossterm` for colors, since `similar` doesn't come with any terminal
pretty printing functionality.

# User-Facing Changes

None - output should be identical.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
2024-03-25 21:13:12 -05:00
Stefan Holderbach
b2c5dc204a
Style: move some Option if/else to method chains (#12285)
- **Use `bool::then` where it simplifies readability**
- **More debatable uses of `bool::then`**
- **Use `Option::filter` in `find_active_overlay`**
2024-03-26 08:35:51 +08:00
Darren Schroeder
2ad68e3702
cleanup coreutils tagging (#12286)
# Description

Cleanup search terms and help usage to be consistent and include
coreutils so people can easily find out which commands are coreutils.


![image](https://github.com/nushell/nushell/assets/343840/09b03b11-19ce-49ec-b0b5-9b8455d1b676)

or
```nushell
help commands | where usage =~ coreutils | reject params input_output
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-03-25 17:13:46 -05:00
David Matos
838fc7e098
Initial implementation for uutils uname (#11684)
Hi,
This PR aims at implementing the first iteration for `uname` using
`uutils`. Couple of things:
* Currently my [PR](https://github.com/uutils/coreutils/pull/5921) to
make the required changes is pending in `uutils` repo.
* I guess the number of flags has to be investigated. Still the tests
cover all of them.


<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- [X] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [X] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used`
to check that you're using the standard code style
- [X] `cargo test --workspace` to check that all tests pass (on Windows
make sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- [X] `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2024-03-25 16:51:50 -05:00
Wind
87c5f6e455
ls, rm, cp, open, touch, mkdir: Don't expand tilde if input path is quoted string or a variable. (#12232)
# Description
Fixes:  #11887
Fixes: #11626

This pr unify the tilde expand behavior over several filesystem relative
commands. It follows the same rule with glob expansion:
|  command  |  result |
| ----------- |  ------ |
| ls ~/aaa  | expand tilde
| ls "~/aaa"  | don't expand tilde
| let f = "~/aaa"; ls $f | don't expand tilde, if you want to: use `ls
($f \| path expand)`
| let f: glob = "~/aaa"; ls $f | expand tilde, they don't expand on
`mkdir`, `touch` comamnd.

Actually I'm not sure for 4th item, currently it's expanding is just
because it followes the same rule with glob expansion.

### About the change
It changes `expand_path_with` to accept a new argument called
`expand_tilde`, if it's true, expand it, if not, just keep it as `~`
itself.

# User-Facing Changes
After this change, `ls "~/aaa"` won't expand tilde.

# Tests + Formatting
Done
2024-03-25 10:08:38 +08:00
Marc Schreiber
e7bdd08a04
Send LSP Completion Item Kind (#11443)
# Description

This commit fills in the completion item kind into the
`textDocument/completion` response so that LSP client can present more
information to the user.

It is an improvement in the context of #10794

# User-Facing Changes

Improved information display in editor's intelli-sense menu


![output](https://github.com/nushell/nushell/assets/16558417/991dc0a9-45d1-4718-8f22-29002d687b93)
2024-03-24 20:14:12 -05:00
Doru
d1a8992590
Initial --params implementation (#12249)
# Description
This PR adds a `--params` param to `query db`. This closes #11643.

You can't combine both named and positional parameters, I think this
might be a limitation with rusqlite itself. I tried using named
parameters with indices like `{ ':named': 123, '1': "positional" }` but
that always failed with a rusqlite error. On the flip side, the other
way around works: for something like `VALUES (:named, ?)`, you can treat
both as positional: `-p [hello 123]`.

This PR introduces some very gnarly code repetition in
`prepared_statement_to_nu_list`. I tried, I swear; the compiler wasn't
having any of it, it kept telling me to box my closures and then it said
that the reference lifetimes were incompatible in the match arms. I gave
up and put the mapping code in the match itself, but I'm still not
happy.

Another thing I'm unhappy about: I don't like how you have to put the
`:colon` in named parameters. I think nushell should insert it if it's
[missing](https://www.sqlite.org/lang_expr.html#parameters). But this is
the way [rusqlite
works](https://docs.rs/rusqlite/latest/rusqlite/trait.Params.html#example-named),
so for now, I'll let it be consistent. Just know that it's not really a
blocker, and it isn't a compatibility change to later make `{ colon: 123
}` work, without the quotes and `:`. This would require allocating and
turning our pretty little `&str` into a `String`, though

# User-Facing Changes
Less incentive to leave yourself open to SQL injection with statements
like `query db $"INSERT INTO x VALUES \($unsafe_user_input)"`.
Additionally, the `$""` syntax being annoying with parentheses plays in
our favor, making users even more likely to use ? with `--params`.

# Tests + Formatting
Hehe
2024-03-24 15:40:21 -05:00