Commit Graph

6010 Commits

Author SHA1 Message Date
Devyn Cairns
9e86e04af0 Merge branch 'main' into ir 2024-07-09 18:39:23 -07:00
Devyn Cairns
78ca94b57c make sure compile errors generally have a span 2024-07-09 18:17:35 -07:00
Devyn Cairns
85922fe50f move IR compile errors into own section in StateWorkingSet 2024-07-09 18:00:46 -07:00
Darren Schroeder
ad8054ebed
update table comments 2024-07-09 19:52:57 -05:00
Devyn Cairns
55a4772f4c redirection shouldn't get passed through unless it's the value that's going to be returned in out_reg 2024-07-09 17:50:35 -07:00
Devyn Cairns
5d083cdaee make instruction builder use labels instead of adjusting placeholder instructions, add IR comments for debug aid 2024-07-09 17:08:03 -07:00
Jack Wright
ff27d6a18e
Implemented a command to expose polar's pivot functionality (#13282)
# Description
Implementing pivot support 

The example below is a port of the [python API
example](https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.pivot.html)

<img width="1079" alt="Screenshot 2024-07-01 at 14 29 27"
src="https://github.com/nushell/nushell/assets/56345/277eb7a2-233b-4070-9d24-c2183805c1b8">

# User-Facing Changes
* Introduction of the `polars pivot` command
2024-07-09 10:17:20 -07:00
Maxim Zhiburt
4cdceca1f7
Fix kv table width issue with header_on_border configuration (#13325)
GOOD CATCH.............................................................
SORRY

I've added a test to catch regression just in case.

close #13319

cc: @fdncred
2024-07-09 09:49:04 -05:00
Devyn Cairns
23fc90a616 set spans of arguments when passed to calls 2024-07-09 06:15:40 -07:00
Devyn Cairns
9e00e8ab2d explicitly set span of binary op output 2024-07-09 06:02:37 -07:00
Devyn Cairns
dcbfff8eb8 just add some variants of push-flag / push-named rather than providing both args 2024-07-09 05:37:49 -07:00
Devyn Cairns
aebdadc674 fix typecheck of list<any> for any, in positional arg 2024-07-09 05:19:07 -07:00
Wind
1964dacaef
Raise error when using o>| pipe (#13323)
# Description
From the feedbacks from @amtoine , it's good to make nushell shows error
for `o>|` syntax.

# User-Facing Changes
## Before
```nushell
'foo' o>| print                                                                                                                                                                                                                     07/09/2024 06:44:23 AM
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #6:1:9]
 1 │ 'foo' o>| print
   ·         ┬
   ·         ╰── expected redirection target
```

## After
```nushell
'foo' o>| print                                                                                                                                                                                                                     07/09/2024 06:47:26 AM
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #1:1:7]
 1 │ 'foo' o>| print
   ·       ─┬─
   ·        ╰── expected `|`.  Redirection stdout to pipe is the same as piping directly.
   ╰────
```

# Tests + Formatting
Added one test

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2024-07-09 07:11:25 -05:00
Devyn Cairns
36faabd36d change the return keyword to return-early, use ShellError::Return :( 2024-07-09 05:09:25 -07:00
Devyn Cairns
f50e22597c fix positionals after spread handling 2024-07-09 04:50:57 -07:00
Devyn Cairns
455ab41303 record spread error on duplicate 2024-07-09 04:45:59 -07:00
Devyn Cairns
f8297abf62 rework named args to also contain their short arg (it was there for a reason) 2024-07-09 04:41:36 -07:00
Devyn Cairns
41654e7656 handle Value::Error early in some places 2024-07-09 04:17:42 -07:00
Devyn Cairns
fc5faef126 fix a todo!() 2024-07-09 04:04:28 -07:00
Devyn Cairns
de3137f72b implement shortcircuiting and/or 2024-07-09 04:00:23 -07:00
Devyn Cairns
abbab2ef90 adjust comment 2024-07-09 03:40:04 -07:00
Devyn Cairns
323e2dbed9 fix handling short-only args. limitation: long args and short args now share the same namespace, effectively 2024-07-09 03:37:49 -07:00
Devyn Cairns
386a7de467 add check for reserved env vars 2024-07-09 03:28:34 -07:00
Devyn Cairns
21f132be9f make compile errors for assignment more like the shell errors 2024-07-09 03:20:23 -07:00
Devyn Cairns
fab24f8e75 add typechecking to block decl call 2024-07-09 03:12:34 -07:00
Ian Manske
e98b2ceb8c
Path migration 1 (#13309)
# Description
Part 1 of replacing `std::path` types with `nu_path` types added in
#13115.
2024-07-09 17:25:23 +08:00
Devyn Cairns
1cd8279ad5 remove nu/do --use-ir, add NU_USE_IR environment variable, tested at start and by do 2024-07-09 00:26:46 -07:00
Devyn Cairns
1ce2096b72 fix clippy. check pr: PASS 2024-07-08 21:10:41 -07:00
Devyn Cairns
0a399011e3 fix redirection, all tests passing 2024-07-08 20:57:02 -07:00
Devyn Cairns
7958cda54e fix double close file with out/err same 2024-07-08 20:19:21 -07:00
Devyn Cairns
6a8169e8ba add specific error for match guard bool 2024-07-08 20:13:50 -07:00
Devyn Cairns
f026a07fe3 fix has_flag on false value 2024-07-08 19:59:39 -07:00
Devyn Cairns
4878d7250f fix let: glob cast from string 2024-07-08 19:54:40 -07:00
Devyn Cairns
ea3849da17 fix all of the error handling tests, mostly by making drain handle external exit codes properly 2024-07-08 19:48:25 -07:00
Devyn Cairns
6e683cd9f5 fix argument formatting issues 2024-07-08 19:03:46 -07:00
Devyn Cairns
2d4355b573 fix issues with subpath $env.foo.bar.baz record default code 2024-07-08 19:01:20 -07:00
Devyn Cairns
74218a8fff check-external-failed is a little wider 2024-07-08 18:51:46 -07:00
Devyn Cairns
fceaefcfaf fix behavior of loops with external stream results (should terminate) 2024-07-08 18:50:56 -07:00
Devyn Cairns
5e04ab2f14 add check for a failed external call to try code 2024-07-08 17:48:14 -07:00
Devyn Cairns
855b76eb2f fix redirection to save 2024-07-08 15:50:05 -07:00
Devyn Cairns
b7225f4c0e tweak view ir desc 2024-07-08 15:27:18 -07:00
Devyn Cairns
5c5db1bd54 add check for error redirection for pipe error mode 2024-07-08 15:14:35 -07:00
Devyn Cairns
38884eec73 add explicit numbering for allocated files, fix some err redirection stuff 2024-07-08 13:58:41 -07:00
Devyn Cairns
2807717245 attempt to use a file stack for redirection, but realized that both out and err can be separate so need to be able to reference both 2024-07-07 23:08:16 -07:00
Devyn Cairns
689cc49663 support calling with the redirection mode of the caller 2024-07-07 20:17:55 -07:00
Ian Manske
399a7c8836
Add and use new Signals struct (#13314)
# Description
This PR introduces a new `Signals` struct to replace our adhoc passing
around of `ctrlc: Option<Arc<AtomicBool>>`. Doing so has a few benefits:
- We can better enforce when/where resetting or triggering an interrupt
is allowed.
- Consolidates `nu_utils::ctrl_c::was_pressed` and other ad-hoc
re-implementations into a single place: `Signals::check`.
- This allows us to add other types of signals later if we want. E.g.,
exiting or suspension.
- Similarly, we can more easily change the underlying implementation if
we need to in the future.
- Places that used to have a `ctrlc` of `None` now use
`Signals::empty()`, so we can double check these usages for correctness
in the future.
2024-07-07 22:29:01 +00:00
YizhePKU
152fb5be39
Fix PWD-aware command hints (#13024)
This PR fixes PWD-aware command hints by sending PWD to the Reedline
state in every REPL loop. This PR should be merged along with
https://github.com/nushell/reedline/pull/796.

Fixes https://github.com/nushell/nushell/issues/12951.
2024-07-07 11:43:22 -05:00
Reilly Wood
83081f9852
explore: pass config to views at creation time (#13312)
cc: @zhiburt

This is an internal refactoring for `explore`.

Previously, views inside `explore` were created with default/incorrect
configuration and then the correct configuration was passed to them
using a function called `setup()`. I believe this was because
configuration was dynamic and could change while `explore` was running.

After https://github.com/nushell/nushell/pull/10259, configuration can
no longer be changed on the fly. So we can clean this up by removing
`setup()` and passing configuration to views when they are created.
2024-07-07 08:09:59 -05:00
Devyn Cairns
6ce5530fc2
Make into bits produce bitstring stream (#13310)
# Description

Fix `into bits` to have consistent behavior when passed a byte stream.

# User-Facing Changes

Previously, it was returning a binary on stream, even though its
input/output types don't describe this possibility. We don't need this
since we have `into binary` anyway.

# Tests + Formatting
Tests added
2024-07-07 08:00:57 -05:00
goldfish
5af8d62666
Fix from toml to handle toml datetime correctly (#13315)
# Description

fixed #12699

When bare dates or naive times are specified in toml files, `from toml`
returns invalid dates or times.
This PR fixes the problem to correctly handle toml datetime.

The current version command returns the default datetime
(`chrono::DateTime::default()`) if the datetime parse fails. However, I
felt that this behavior was a bit unfriendly, so I changed it to return
`Value::string`.

# User-Facing Changes

The command returns a date with default time and timezone if a bare date
is specified.

```
~/Development/nushell> "dob = 2023-05-27" | from toml
╭─────┬────────────╮
│ dob │ a year ago │
╰─────┴────────────╯
~/Development/nushell> "dob = 2023-05-27" | from toml |
Sat, 27 May 2023 00:00:00 +0000 (a year ago)
~/Development/nushell>                            
```

If a bare time is given, a time string is returned.

```
~/Development/nushell> "tm = 11:00:00" | from toml
╭────┬──────────╮
│ tm │ 11:00:00 │
╰────┴──────────╯
~/Development/nushell> "tm = 11:00:00" | from toml | get tm
11:00:00
~/Development/nushell>  
```

# Tests + Formatting

When I ran tests, `commands::touch::change_file_mtime_to_reference`
failed with the following error.
The error also occurs in the master branch, so it's probably unrelated
to these changes.
(maybe a problem with my dev environment)

```
$ ~/Development/nushell> toolkit check pr

~~~~~~~~

test usage_start_uppercase ... ok
test format_conversions::yaml::convert_dict_to_yaml_with_integer_floats_key ... ok
test format_conversions::yaml::convert_dict_to_yaml_with_boolean_key ... ok
test format_conversions::yaml::table_to_yaml_text_and_from_yaml_text_back_into_table ... ok
test quickcheck_parse ... ok
test format_conversions::yaml::convert_dict_to_yaml_with_integer_key ... ok

failures:

---- commands::touch::change_file_mtime_to_reference stdout ----
=== stderr

thread 'commands::touch::change_file_mtime_to_reference' panicked at crates/nu-command/tests/commands/touch.rs:298:9:
assertion `left == right` failed
  left: SystemTime { tv_sec: 1720344745, tv_nsec: 862392750 }
 right: SystemTime { tv_sec: 1720344745, tv_nsec: 887670417 }


failures:
    commands::touch::change_file_mtime_to_reference

test result: FAILED. 1542 passed; 1 failed; 32 ignored; 0 measured; 0 filtered out; finished in 12.04s

error: test failed, to rerun pass `-p nu-command --test main`
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🔴 `toolkit test`
-  `toolkit test stdlib`

~/Development/nushell> toolkit test stdlib
   Compiling nu v0.95.1 (/Users/hiroki/Development/nushell)
   Compiling nu-cmd-lang v0.95.1 (/Users/hiroki/Development/nushell/crates/nu-cmd-lang)
    Finished dev [unoptimized + debuginfo] target(s) in 6.64s
     Running `target/debug/nu --no-config-file -c '
        use crates/nu-std/testing.nu
        testing run-tests --path crates/nu-std
    '`
2024-07-07T19:00:20.423|INF|Running from_jsonl_invalid_object in module test_formats
2024-07-07T19:00:20.436|INF|Running env_log-prefix in module test_logger_env

~~~~~~~~~~~

2024-07-07T19:00:22.196|INF|Running debug_short in module test_basic_commands
~/Development/nushell> 
```

# After Submitting

nothing
2024-07-07 07:55:06 -05:00