1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-02 23:51:49 +02:00
Commit Graph

89 Commits

Author SHA1 Message Date
JT
6e733f49bc Require block params ()
* Require block params

* Improve errors
2022-02-17 06:40:24 -05:00
JT
fc88a8538b Make let-env work like let ()
* Make let-env work like let

* Fix tests
2022-02-09 13:41:41 -05:00
JT
f9e1c4ef50 Use 'table' on scripts and -c commands ()
* Use 'table' on scripts and -c commands

* Fix tests

* Oops, missed a spot
2022-02-09 05:58:54 -05:00
JT
d70d91e559 Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
fdce6c49ab engine-q merge 2022-02-07 19:11:34 +00:00
JT
cc1b784e3d Add initial nu-test-support port ()
* Add initial nu-test-support port

* finish changing binary name

* Oops, these aren't Windows-safe tests
2022-02-02 15:59:01 -05:00
c9c6bd4836 Create errors from tables. ()
```
> [
  [          msg,                 labels,                      span];
  ["The message", "Helpful message here", ([[start, end]; [0, 141]])]
] | error make

error: The message
  ┌─ shell:1:1
  │
1 │ ╭ [
2 │ │   [          msg,                 labels,                      span];
3 │ │   ["The message", "Helpful message here", ([[start, end]; [0, 141]])]
  │ ╰─────────────────────────────────────────────────────────────────────^ Helpful message here
```

Adding a more flexible approach for creating error values. One use case, for instance is the
idea of a test framework. A failed assertion instead of printing to the screen it could create
tables with more details of the failed assertion and pass it to this command for making a full
fledge error that Nu can show. This can (and should) be extended for capturing error values as well
in the pipeline. One could also use it for inspection.

For example: `.... | error inspect { # inspection here }`

or "error handling" as well, like so: `.... | error capture { fix here }`

However, we start here only with `error make` that creates an error value for you with limited support for the time being.
2021-09-02 21:07:26 -05:00
b8e2bdd6b1 Allow different names for ...rest ()
* Allow different names for ...rest

* Resolves 

* This change requires an explicit name for the rest argument in `WholeStreamCommand`,
  which is why there are so many changed files.

* Remove redundant clone

* Add tests
2021-08-27 05:58:53 +12:00
88817a8f10 Allow environment variables to be hidden ()
* Allow environment variables to be hidden

This change allows environment variables in Nushell to have a value of
`Nothing`, which can be set by the user by passing `$nothing` to
`let-env` and friends.

Environment variables with a value of Nothing behave as if they are not
set at all. This allows a user to shadow the value of an environment
variable in a parent scope, effectively removing it from their current
scope. This was not possible before, because a scope can not affect its
parent scopes.

This is a workaround for issues like .

Additionally, this allows a user to simultaneously set, change and
remove multiple environment variables via `load-env`. Any environment
variables set to $nothing will be hidden and thus act as if they are
removed. This simplifies working with virtual environments, which rely
on setting multiple environment variables, including PATH, to specific
values, and remove/change them on deactivation.

One surprising behavior is that an environment variable set to $nothing
will act as if it is not set when querying it (via $nu.env.X), but it is
still possible to remove it entirely via `unlet-env`. If the same
environment variable is present in the parent scope, the value in the
parent scope will be visible to the user. This might be surprising
behavior to users who are not familiar with the implementation details.

An additional corner case is the the shorthand form of `with-env` does
not work with this feature. Using `X=$nothing` will set $nu.env.X to the
string "$nothing". The long-form works as expected: `with-env [X
$nothing] {...}`.

* Remove unused import

* Allow all primitives to be convert to strings
2021-08-26 08:15:58 -05:00
6db5692be4 Only allow unaliasing in current scope, add tests ()
* unalias only removes aliases in the current scope

* Add a test and fix previous ones which did not function as expected
2021-08-19 19:05:36 +12:00
JT
ead4029d49 Bump rustyline and add unalias test () 2021-08-18 05:55:34 +12:00
9bd408449e Add the ability to remove and list aliases ()
* Add the ability to remove and list aliases

* Fix failing unit tests

* Add a test to check unalias shadowing blocks
2021-08-17 08:56:35 -05:00
JT
b6728efcd4 in/not-in for strings () 2021-08-07 09:49:37 +12:00
1e15f26e98 fix interpolated strings when using unicode ()
* fix interpolated strings when using unicode

* added test case
2021-07-29 19:07:34 -05:00
JT
69fa040361 Fix nothing string comparison () 2021-07-08 07:21:02 +12:00
JT
b1970f79ee Add support for arbitrarily nested subcommands () 2021-06-26 09:09:06 +12:00
JT
93b5f3f421 Make lexing configurable wrt newlines () 2021-06-25 17:50:24 +12:00
JT
318d13ed58 Add built-in var to refer to pipeline values () 2021-06-21 12:31:01 +12:00
9e39284de9 Add unlet_env command ()
* Add ability to remove env variables

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Implement unlet_env command

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Update parameter description

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Migrate to new filestructure

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Added tests for unlet-env

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Formatting

Signed-off-by: nathom <nathanthomas707@gmail.com>
2021-06-19 15:00:07 +12:00
JT
e8a2250ef8 Improve expr parse ()
* Require '-' to be a number for math

* Add test

* improve parse logic, add test
2021-06-10 05:17:45 +12:00
JT
16faafb7a8 Rename the use of invocation to subexpression ()
* Rename the use of invocation to subexpression

* Fix test name
2021-06-07 20:08:35 +12:00
JT
a2e6f5ebdb Add hex, octal, binary () 2021-06-06 17:14:51 +12:00
JT
1d0d0425d4 More fixes for bigint duration () 2021-06-05 04:54:18 +12:00
JT
131b5b56d7 Finish removing arg deserialization ()
* WIP remove process

* WIP

* WIP

* Finish removing arg deserialization
2021-06-04 18:23:57 +12:00
JT
290c712cde Retain tag when accessing a var () 2021-06-02 19:49:14 +12:00
JT
41834d16d6 Allow aliases to expand and ignore painting outside of lines () 2021-05-26 17:58:32 +12:00
1ee51f2afa Add the load-env command ()
* Add the load-env command

load-env can be used to add environment variables dynamically via an
InputStream. This allows developers to create tools that output environment
variables as key-value pairs, then have the user load those variables in using
load-env. This supplants most of the need for an `eval` command, which is
mostly used in POSIX envs for setting env vars.

Fixes 

* fixup! Add the load-env command
2021-05-26 06:18:20 +12:00
JT
5fcc7f2328 Fix bad operator () 2021-05-24 17:27:10 +12:00
JT
751de20f93 Do a bit more cleanup of block params ()
* Do a bit more cleanup of block params

* Do a bit more cleanup of block params
2021-05-21 19:04:27 +12:00
JT
4fdbf30308 Paren interpolation ()
* Switch interp to use parens

* improve interp parsing
2021-05-21 10:55:38 +12:00
JT
20f6114617 Improve block params () 2021-05-20 16:26:54 +12:00
JT
efac712f62 Fix string interp/shorthand overlap () 2021-05-12 16:20:29 +12:00
JT
311c0e3f50 Simplify string interpolation ()
* [DRAFT] simplify string interpolation

* Fix test
2021-05-12 13:53:57 +12:00
JT
25a8caa9b0 Simplify expressions ()
* WIP: experiment with simpler expressions

* fix simple invoke

* update tests

* fix a few tests

* Make paren parsing more robust

* fix external args

* Remove old invocation

* Update tests

* Update tests
2021-05-12 13:01:48 +12:00
JT
02d5729941 Properly evaluate dynamic blocks () 2021-04-21 14:31:54 +12:00
JT
61768aa2fd Fix parsing dot dot path () 2021-04-20 08:18:29 +12:00
611103d211 Fix Running echo .. starts printing integers forever () 2021-04-16 07:07:06 +12:00
52d69bb021 Fix Rest arg is not optional () 2021-04-12 14:37:36 +12:00
e5621dea58 Remove yr and mon ()
* Remove `yr` and `mon`

* Remove usage of mon in test

* Fix test
2021-04-05 06:19:33 +12:00
7e184b58b2 Fix warnings for Rust 1.51 ()
* Fix warnings for Rust 1.51

* More fixes

* More fixes
2021-03-26 21:26:57 +13:00
7dc1d6a350 Extract .nu-env tests and more granularity ()
The autoenv logic mutates environment variables in the running session as
it operates and decides what to do for trusted directories containing `.nu-env`
files. Few of the ways to interact with it were all in a single test function.

We separate out all the ways that were done in the single test function to document
 it better. This will greatly help once we start refactoring our way out from setting
 environment variables this way to just setting them to `Scope`.

This is part of an on-going effort to keep variables (`PATH` and `ENV`)
in our `Scope` and rely on it for everything related to variables.

We expect to move away from setting (`std::*`) envrironment variables in the current
running process. This is non-trivial since we need to handle cases from vars
coming in from the outside world, prioritize, and also compare to the ones
we have both stored in memory and in configuration files.

Also to send out our in-memory (in `Scope`) variables properly to external
programs once we no longer rely on `std::env` vars from the running process.
2021-02-18 20:24:27 -05:00
48a90fea70 Fix let-env () 2021-02-15 20:58:51 +13:00
b202951c1d fix prompts on startup ()
* fix prompts on startup

* Try again
2021-02-15 20:14:16 +13:00
b403fb1275 nu-parser + nu-protocol: switch to metric for KB, MB, GB, add KiB, MiB, GiB units ()
fixes inconsistency with formatting/rendering which uses standard Rust byte_unit
https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
2021-02-10 15:31:12 +13:00
44e088c6fe Move filesize to use bigint ()
* Move filesize to be bigint-sized

* Add tests and fix filesize display

* clippy
2021-01-30 11:35:18 +13:00
52dc04a35a Error on bad row in column path ()
* Error on bad row in column path

* Add more pathing tests
2021-01-22 18:14:13 -05:00
a4b8d4a098 Add rest support to blocks () 2021-01-23 10:28:32 +13:00
899d324a9c fix: error Variable not in scope for a def parameter ()
adding tests to notice regressions on this issue

Co-authored-by: hk <alexhaka10@protonmail.com>
2021-01-20 07:21:11 +13:00
99117ff2ef Fix reading/writing bigint and bigdecimal () 2021-01-09 12:53:59 +13:00
17a433996e rename set/set-env to let/let-env () 2021-01-05 12:30:55 +13:00