Commit Graph

814 Commits

Author SHA1 Message Date
Björn Richter
cb18dd5200
Add decimals to int when using into string --decimals (#6085)
* Add decimals to int when using `into string --decimals`

* Add tests for `into string` when converting int with `--decimals`

* Apply formatting

* Merge `into_str` test files

* Comment out unused code and add TODOs

* Use decimal separator depending on system locale

* Add test helper to run closure in different locale

* Add tests for int-to-string conversion using different locales

* Add utils function to get system locale

* Add panic message when locking mutex fails

* Catch and resume panic later to prevent Mutex poisoning when test fails

* Move test to `nu-test-support` to keep `nu-utils` free of `nu-*` dependencies

See https://github.com/nushell/nushell/pull/6085#issuecomment-1193131694

* Rename test support fn `with_fake_locale` to `with_locale_override`

* Move `get_system_locale()` to `locale` module

* Allow overriding locale with special env variable (when not in release)

* Use special env var to override locale during testing

* Allow callback to return a value in `with_locale_override()`

* Allow multiple options in `nu!` macro

* Allow to set locale as `nu!` macro option

* Use new `locale` option of `nu!` macro instead of `with_locale_override`

Using the `locale` options does not lock the `LOCALE_OVERRIDE_MUTEX`
mutex in `nu-test-support::locale_override` but instead calls the `nu`
command directly with the `NU_LOCALE_OVERRIDE` environment variable.
This allows for parallel test excecution.

* Fix: Add option identifier for `cwd` in usage of `nu!` macro

* Rely on `Display` trait for formatting `nu!` macro command

- Removed the `DisplayPath` trait
- Implement `Display` for `AbsolutePath`, `RelativePath` and
  `AbsoluteFile`

* Default to locale `en_US.UTF-8` for tests when using `nu!` macro

* Add doc comment to `nu!` macro

* Format code using `cargo fmt --all`

* Pass function directly instead of wrapping the call in a closure

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

* Pass function to `or_else()` instead of calling it inside `or()`

https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

* Fix: Add option identifier for `cwd` in usage of `nu!` macro
2022-08-12 21:13:50 -05:00
Jakub Žádník
c3efb12733
Allow overlays to import prefixed definitions (#6301)
* WIP

* Fix overlay prefix not preserving correctly

* Work around failing REPL tests

* Remove wrong code when removing with --keep-custom
2022-08-12 21:06:51 +03:00
Reilly Wood
d885258dc7
Clarify external command error (#6308) 2022-08-13 05:34:10 +12:00
Stefan Holderbach
c2f4969d4f
Clippy fix for Rust 1.63 (#6299)
Take more sensitive lints into account

Somewhat ugly in some cases is the replacement of `.get(0)` with
`.first()`
2022-08-11 11:54:54 -05:00
JT
121b801baa
bump dev version ahead of language changes (#6267) 2022-08-09 08:15:41 +12:00
Justin Ma
cc99df5ef1
upgrade chrono to v0.4.20 (#6235) 2022-08-05 06:53:01 -05:00
Darren Schroeder
cdeb8de75d
replace the regex crate with the fancy-regex crate (#6227) 2022-08-04 14:51:02 -05:00
Kangaxx-0
ebf845f431
Change how to identify custom comamnd (#6187)
Co-authored-by: Frank <v-frankz@microsoft.com>
2022-08-02 18:40:07 -05:00
WindSoilder
586c0ea3d8
Add bits not command (#6143)
Add `bits not`

Options: `--number-bytes` and `--sized`
2022-07-30 11:25:44 +02:00
Jakub Žádník
d6f4189c7b
Fix file lookup in parser keywords; Refactor nu_repl (#6185)
* Fix file lookup in parser keywords

* Make nu_repl a testbin; Fix wrong cwd test error
2022-07-29 23:42:00 +03:00
Darren Schroeder
7a820b1304
add a new welcome banner to nushell (#6163)
* add a new welcome banner to nushell

* remove top line

* tweaked colors and wording

* changed to dimmed white

* removed a comment

* make config nu stand out a little

* fix type-o
2022-07-30 05:50:12 +12:00
Justin Ma
767201c40d
bump to 0.66.3 dev version (#6183) 2022-07-30 05:48:10 +12:00
Jakub Žádník
2cffff0c1b
Allow modules to use other modules (#6162)
* Allow private imports inside modules

Can call `use ...` inside modules now.

* Add more tests

* Add a leak test

* Refactor exportables; Prepare for 'export use'

* Fix description

* Implement 'export use' command

This allows re-exporting module's commands and aliases from another
module.

* Add more tests; Fix import pattern list strings

The import pattern strings didn't trim the surrounding quotes.

* Add ignored test
2022-07-29 11:57:10 +03:00
JT
e049ca8ebf
bump to 0.66.2 dev version (#6157) 2022-07-28 11:38:52 +12:00
Jakub Žádník
c92211c016
Use relative paths as file-relative when parsing a file (#6150)
* Make function local (not used anywhere else)

* Use path relative to the parsed file

* Do not use real cwd at all
2022-07-27 18:36:56 +03:00
JT
d42cfab6ef
bump to 0.66.1 dev version (#6140) 2022-07-27 13:15:04 +12:00
JT
c6cb491e77
bump to 0.66 (#6137) 2022-07-27 07:56:14 +12:00
Darren Schroeder
d856ac92f4
expand durations to include month, year, decade (#6123)
* expand durations to include month, year, decade

* remove commented out fn

* oops, found more debug comments

* tweaked tests for the new way, borrowed heavily from chrono-humanize-rs

* clippy

* grammar
2022-07-26 08:05:37 -05:00
nibon7
72c27bd095
Fix PipelineData::print when table is overridden (#6129)
* Fix PipelineData::print when `table` is overridden

Fixes #6113

Signed-off-by: nibon7 <nibon7@163.com>

* don't use deprecated `is_custom_command`

Signed-off-by: nibon7 <nibon7@163.com>

* add test

Signed-off-by: nibon7 <nibon7@163.com>
2022-07-25 18:41:30 -05:00
JT
475d32045f
Revert "Refactor external command (#6083)" (#6116)
This reverts commit 0646f1118c.
2022-07-26 05:37:15 +12:00
nibon7
5a5c65ee4b
Simplify PipelineData::print (#6119)
* Simplify PipelineData::print

Signed-off-by: nibon7 <nibon7@163.com>

* make write_all_and_flush to be associated function

Signed-off-by: nibon7 <nibon7@163.com>
2022-07-25 06:38:21 -05:00
Matthew Ma
87e2fa137a
Allow cp multiple files at once (#6114)
* Allow cp multiple files at once

* Expand destination with expand_ndots
2022-07-25 10:42:25 +03:00
Kangaxx-0
0646f1118c
Refactor external command (#6083)
Co-authored-by: Frank <v-frankz@microsoft.com>
2022-07-21 19:56:57 -04:00
pwygab
ae765c71fd
add config option to limit external command completions (#6076)
* add config option to limit external command completions

* fmt

* small change

* change name in config

* change name in config again
2022-07-19 12:39:50 -05:00
Jakub Žádník
26f31da711
Split merging of parser delta and stack environment (#6005)
* Remove comment

* Split delta and environment merging

* Move table mode to a more logical place

* Cleanup

* Merge environment after reading default_env.nu

* Fmt
2022-07-14 17:09:27 +03:00
Kangaxx-0
ceafe434b5
Downgrade crate typetag to 0.1.8 (#6044)
Co-authored-by: Frank <v-frankz@microsoft.com>
2022-07-13 14:38:29 -05:00
Maxim Zhiburt
217c2bae99
Move wrap responsibility on tabled (#5999)
* nu_table/ Replace wrap.rs logic by tabled::Width::wrap

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Rename wrap.rs to width_control.rs

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Add configuration of trimming

```
let-env config = ($env.config | upsert table_trim { methodology: 'wrapping', wrapping_try_keep_words: false })
let-env config = ($env.config | upsert table_trim { methodology: 'truncating', truncatting_suffix: '...@@...' })
```

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Fix right padding issue

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Fix trancate issue

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Fix spelling in config

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* nu_table: Update tabled dependency

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Update default_config.nu with a table_trim options

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-07-12 11:23:50 -05:00
JT
a5470b2362
use simpler reedline (#6016) 2022-07-12 13:25:31 +12:00
Jakub Žádník
f3036b8cfd
Allow keeping selected environment variables from removed overlay (#6007)
* Allow keeping selected env from removed overlay

* Remove some duplicate code

* Change --keep-all back to --keep-custom

Because, apparently, you cannot have a named flag called --keep-all,
otherwise tests fail?

* Fix missing line and wrong test value
2022-07-11 23:58:28 +03:00
Darren Schroeder
9b6b817276
update some dependencies (#6009)
* update some dependencies

* there may be some bugs here but it seems to compile and run

* clippy
2022-07-11 11:18:06 -05:00
WindSoilder
9e3c64aa84
Add bytes collect, bytes remove, bytes build cmd (#6008)
* add bytes collect

* index_of support searching from end

* add bytes remove

* make bytes replace work better for empty pattern

* add bytes build

* remove comment

* tweak words

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2022-07-11 06:26:00 -05:00
Jakub Žádník
3676a8a48d
Expand Hooks Functionality (#5982)
* (WIP) Initial messy support for hooks as strings

* Cleanup after running condition & hook code

Also, remove prints

* Move env hooks eval into its own function

* Add env change hooks to simulator

* Fix hooks simulator not running env hooks properly

* Add missing hooks test file

* Expand hooks tests

* Add blocks as env hooks; Preserve hook environment

* Add full eval to pre prompt/exec hooks; Fix panic

* Rename env change hook back to orig. name

* Print err on test failure; Add list of hooks test

* Consolidate condition block; Fix panic; Misc

* CHange test to use real file

* Remove unused stuff

* Fix potential panics; Clean up errors

* Remove commented unused code

* Clippy: Fix extra references

* Add back support for old-style hooks

* Reorder functions; Fmt

* Fix test on Windows

* Add more test cases; Simplify some error reporting

* Add more tests for setting correct before/after

* Move pre_prompt hook to the beginning

Since we don't have a prompt or blocking on user input, all hooks just
follow after each other.
2022-07-10 13:45:46 +03:00
pwygab
47f6d20131
adds better error for failed string-to-duration conversions (#5977)
* adds better error for failed string-to-duration conversions

* makes error multi-spanned, conveys literally all the information available now
2022-07-07 05:54:38 -05:00
Justin Ma
de162c9aea
Bump to 0.65.1 dev version (#5962) 2022-07-06 16:25:09 +12:00
JT
0d40d0438f
bump to 0.65 (#5952) 2022-07-05 17:54:16 +12:00
WindSoilder
1e8212a938
add bytes len (#5945) 2022-07-04 05:51:07 -05:00
Justin Ma
4e90b478b7
Add bit operator: bit-xor (#5940) 2022-07-03 06:45:20 -05:00
JT
a48616697a
Rename bitwise operators for readability (#5937) 2022-07-02 17:05:02 -05:00
Justin Ma
b82dccf0bd
Add band and bor operator for bit operations (#5936)
* Add `band` and `bor` Operator

* Add tests
2022-07-02 13:03:36 -05:00
WindSoilder
84caf8859f
add -e flag to print, to print the value to stderr (#5935)
* Refactor: make stdout write all and flush as generic function

* support print to stderr
2022-07-02 09:54:49 -05:00
Justin Ma
3917fda7ed
Update #4202: Add shift operator bshl and bshr for integers (#5928)
* Update #4202: Add shift operator bshl and bshr for integers

* Add more tests
2022-07-02 06:48:43 -05:00
Michael Angerman
58fa2e51a2
update crate thiserror to version 1.0.31 in crates nu-cli, nu-command, nu-parser, nu-protocol (#5919) 2022-06-30 13:55:01 -07:00
pwygab
a0db4ce747
Better error handling using do (#5890)
* adds `capture-errors` flag for `do`

* adds `get-type` core command to get type

* fmt

* add tests in example

* fmt

* fix tests

* manually revert previous changes related to `get-type`

* adds method to check for error name using `into string`

* fix clippy
2022-06-29 20:01:34 -05:00
Benoît Cortier
228ede18cf
build: update miette dependency (#5889) 2022-06-26 07:03:38 -05:00
Benoît Cortier
173d60d59d
Deprecate hash base64, extend decode and add encode commands (#5863)
* feat: deprecate `hash base64` command

* feat: extend `decode` and `encode` command families

This commit
- Adds `encode` command family
- Backports `hash base64` features to `encode base64` and `decode base64` subcommands.
- Refactors code a bit and extends tests for encodings
- `decode base64` returns a binary `Value` (that may be decoded into a string using `decode` command)

* feat: add `--binary(-b)` flag to `decode base64`

Default output type is now string, but binary can be requested using this new flag.
2022-06-26 00:35:23 +03:00
JT
f2989bf704
Move input/output type from Command to Signature (#5880) 2022-06-26 09:23:56 +12:00
JT
575ddbd4ef
Clippy and remove unused is_binary (#5879) 2022-06-26 08:20:28 +12:00
WindSoilder
f02076daa8
fix plugin path with whitespace (#5871) 2022-06-24 12:44:22 -05:00
JT
533e04a60a
Bump to 0.64.1 dev version (#5865) 2022-06-24 16:47:00 +12:00
Michael Angerman
bc48b4553c
Move the history and tutor commands out of core_commands (#5813)
* move history and tutor commands from core to misc

* add in the Misc Category for the history and tutor commands
2022-06-16 09:58:38 -07:00