Commit Graph

1371 Commits

Author SHA1 Message Date
JT
55c243a17b
Update Cargo.toml (#3526) 2021-06-01 19:32:44 +12:00
JT
df526f73be
Bump to 0.32 (#3521)
* Bump to 0.32

* Bump to 0.32
2021-06-01 08:14:50 +12:00
Christian Menges
29a77fd6ae
Bump rusqlite from 0.24.2 to 0.25.3 (#3523) 2021-06-01 07:34:51 +12:00
ahkrr
be9ebd9e18
fix: filename quoting # and update and unify surf dependency (#3524)
* fix: filenames with '#' don't get quoted #3496

* updating and unifying dependency surf

* adding hyper-client

Co-authored-by: ahkrr <alexhk@protonmail.com>
2021-05-31 10:22:46 -05:00
Christian Menges
01f1208ad1
to sqlite: Fix panic caused by empty tables (#3522) 2021-05-31 21:46:07 +12:00
ahkrr
9dbb3e80fe
feat: add attribute selection to nu_plugion_selector (#3519)
This allows the user to specify for example 
selector a -t href 
to downselect based on an attribute

Co-authored-by: ahkrr <alexhk@protonmail.com>
2021-05-30 11:49:43 -05:00
Andrés N. Robalino
a5c14ba7d4
Ensure correct partial key=value flag. (#3518) 2021-05-29 23:19:58 -05:00
Lily Mara
4b11b283ac
Resolve issues with rm * globbing (#3516)
Using the `*` wildcard should not attempt to delete files with a leading dot
unless the more explicit `.*` is used. `rm *` should also not attempt to delete
the current directory or its parent directory (`.` and `..`). I have resolved
this bug as well in a less satisfactory way. I think it may be the case that we
can only disambiguate the `.` and `..` path segments by using `Path::display`.
Here is a short list of alternatives that I tried:

- `Path::ends_with()` can detect `/..` but not `/.`.
- `Path::iter()` and `Path::components()` leave out `/.`.
- `Path::file_name()` normalizes `/.` to the parent component's file name.

Fixes #3508
2021-05-30 15:36:36 +12:00
Andrés N. Robalino
6fdfc84904
Parse key=value named flag support. (#3515) 2021-05-29 20:42:03 -05:00
Darren Schroeder
ed515cbc0c
update keybindings to support new rustyline functionality (#3511)
* update keybindings to support new rustyline functionality

* remove some keybindings comments

* fix wasm build

* fixed multiline editing binding
2021-05-28 15:10:04 -05:00
Darren Schroeder
87a6d7166c
remove expect so that config doesn't fail (#3510) 2021-05-29 05:23:15 +12:00
JT
55baee9a9a
Cleanup let varname and rhs (#3507) 2021-05-28 19:48:54 +12:00
JT
0886afe650
Fix for in (#3506)
* Fix for..in examples

* Fix for..in examples
2021-05-28 11:20:33 +12:00
JT
872f6166e1
Add for..in command (#3504) 2021-05-28 10:32:45 +12:00
Jakub Žádník
fe348e236f
Convert do command to engine-p; Fix flag name (#3503)
Renamed "ignore_errors" to "ignore-errors" to be aligned with nushell's
naming conventions.
2021-05-28 10:12:52 +12:00
Darren Schroeder
e0f083d117
fix polars compile warnings (#3501) 2021-05-27 12:30:46 -05:00
Darren Schroeder
48171f8e24
remove str from (#3500) 2021-05-27 12:18:02 -05:00
Darren Schroeder
bcdf74562b
remove into int references (#3499) 2021-05-27 11:35:25 -05:00
Fernando Herrera
3a5ee1aed0
Dataframe commands (#3498)
* Sample command

* Join command with checks

* More dataframes commands

* Groupby and aggregate commands

* Missing feature dataframe flag

* Renamed file
2021-05-27 17:09:48 +12:00
Darren Schroeder
d8c4b9c4fb
add locale for ls size (#3497)
* add locale for ls size

* updated to work when it's not an exact match like de_DE when it needs de
2021-05-27 11:02:24 +12:00
Jakub Žádník
6ae7884786
Fix path dots expansion (#3491)
* Fix parser expanding dots where it shouldn't

Previously, the parser would expand "a...b" as "a../..b". Now, >2 dots
are only expanded when the whole path component consists of dots (i.e.,
"..." expands to "../.." while "a...b" stays as it is).

* Respect OS separator when expanding >2 dots

"..." now expands to either "../.." or "..\..", based on the host OS.
2021-05-26 20:17:18 +12:00
JT
41834d16d6
Allow aliases to expand and ignore painting outside of lines (#3492) 2021-05-26 17:58:32 +12:00
Lily Mara
1ee51f2afa
Add the load-env command (#3484)
* 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 #3481

* fixup! Add the load-env command
2021-05-26 06:18:20 +12:00
Darren Schroeder
65ee7aa372
correctly escape pipe in windows/cmd.exe (#3489)
* correctly escape pipe in windows/cmd.exe

* add some comments, take out debug line
2021-05-25 09:19:45 -05:00
Darren Schroeder
ac38ee82f4
error message cleanup for into string (#3488) 2021-05-25 07:49:12 -05:00
JT
5fcc7f2328
Fix bad operator (#3479) 2021-05-24 17:27:10 +12:00
Andrés N. Robalino
3bcc2aad80
Pass command's span correctly when reporting unexpected flags. (#3478)
Not all lite command's first part denotes a real command (for cases like sub commands that it's second lite part accounts for the command name). This is important so that we can refer to it's span correctly. Here we fix to include the command's name span correctly whether it's a command or sub command when reporting missing flag errors.
2021-05-23 19:30:30 -05:00
Tomas Koutsky
6165b6ae77
Add params to do (#3477) 2021-05-24 09:21:41 +12:00
Fernando Herrera
e335e4fddc
Groupby operations on dataframes (#3473)
* Added PolarsStruct enum to implement groupby

* template groupby

* groupby operationi on dataframes
2021-05-23 19:37:04 +12:00
Jakub Žádník
5ab4199d71
Add path separator to char; Update char to engine-p; List all names of all possible chars (#3470)
* Allow querying the current path separator

* Convert char command to engine-p

* Wrap char args into struct

* Add --list option to char command

This lists all the available character names, along with the character
and its unicode points.
2021-05-22 11:48:33 -05:00
Fernando Herrera
f075e2459d
Commands to engine (#3448)
* commands to engine

* Correction of error in parser

* Added detailed regex error to parse

* better regex error parsing

* clippy corrections

* parse example with test

* secondary error for regex

* removed clone in error parser

* Secondary error message
2021-05-22 10:52:04 -05:00
Jakub Žádník
94a26abf21
Implement path relative-to subcommand (#3461)
* Register new path relative-to command

* Implement `path relative-to` subcommand
2021-05-22 09:29:40 -05:00
Leonhard Kipp
bcbdc33049
Use enginep style in enter command (#3469) 2021-05-22 09:27:42 -05:00
Henrik Sjööh
21ef3895b3
delete crates/nu-command/src/commands/date/utc.rs (#3464)
The `date utc` command was removed in this PR:

https://github.com/nushell/nushell/pull/2780

The file was left but is no longer referenced from the parent module
and was not used.

Co-authored-by: Henrik Sjööh <henrik.sjooh@configura.com>
2021-05-22 17:09:50 +12:00
JT
3e99dc01b0
let date commands pull default date (#3463) 2021-05-22 17:02:06 +12:00
Eli Flanagan
2b92e3e8a7
port group-by to engine-p (#3458)
* migrate group-by to engine p

Part of #3390.

* consume positional argument correctly
2021-05-21 21:19:43 -05:00
Darren Schroeder
cb90b90cbf
nothing converted to string should return nothing and not fail (#3459) 2021-05-21 11:06:53 -05:00
Darren Schroeder
9776a252ee
add addition characters that can be hard to work with in nushell (#3457) 2021-05-21 08:04:48 -05:00
JT
751de20f93
Do a bit more cleanup of block params (#3455)
* 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
28388b4e3a
Split unit into duration and filesize (#3453) 2021-05-21 13:21:46 +12:00
JT
4fdbf30308
Paren interpolation (#3452)
* Switch interp to use parens

* improve interp parsing
2021-05-21 10:55:38 +12:00
Darren Schroeder
722f191e82
updated round to support i64 (#3451) 2021-05-20 13:59:19 -05:00
JT
20f6114617
Improve block params (#3450) 2021-05-20 16:26:54 +12:00
Jakub Žádník
3075e2cfbf
Remove rest_args() from evaluated CommandArgs (#3449)
It was too error prone when positional arguments were used with the rest
arguments. Now, you need to explicitly state from which position you
want to count the rest args (e.g., `rest(0)`).
2021-05-20 10:26:23 +12:00
JT
e2973d2176
Add explicit block params (#3444)
* Add explicit block params

* Add explicit block params
2021-05-19 20:23:45 +12:00
JT
0ff08bb63a
Just treat u64 like i64 for now (#3442) 2021-05-19 09:32:37 +12:00
Jakub Žádník
08c0bf52bc
Fix path join argument type and a typo (#3441) 2021-05-19 09:30:37 +12:00
Fernando Herrera
d0229cb96e
Load parquet and json files (#3437)
* Load parquet and json files

* changed csv file error
2021-05-19 07:33:10 +12:00
Darren Schroeder
0612e5ccfb
updated to the latest rustyline (#3439) 2021-05-18 12:36:55 -05:00
Darren Schroeder
1b4f7b34c8
don't let externals break ansi escapes (#3438) 2021-05-17 18:01:34 -05:00
Alex Shadley
86e6fcd309
Negative indexing for range (#3427)
* adds negative indexing to range

* fixes tests to reflect new parsing changes

* removes duplicate definitons

* fmt
2021-05-17 15:08:47 +12:00
Marc Schreiber
dc9cd7d8b9
Add Support for Partial Completions (#3432)
This commit adds a conditional event handler that inserts the next word of the
hint text when the user presses control and right arrow.
2021-05-16 08:43:43 +12:00
Fernando Herrera
c0cc9ce7cd
Dataframe new commands (#3425)
* Folder for dataframe commands

* New commands for dataframe
2021-05-15 19:24:11 +12:00
Darren Schroeder
be2f66397b
re-enable ansi support when externals break it (#3429) 2021-05-15 16:11:21 +12:00
Fernando Herrera
07760b4129
Commands to engine p (#3426)
* hash and into converted

* keep command to engine p

* Update int.rs

Co-authored-by: JT <jonathandturner@users.noreply.github.com>
2021-05-15 16:11:07 +12:00
JT
d79a3130b8
Make the default int an i64 (#3428)
* Make the default int an i64

* fmt

* Fix random integer

* Treat pids as i64 for now
2021-05-14 20:35:09 +12:00
Darren Schroeder
440a589f9e changed comment slightly 2021-05-13 14:21:16 -05:00
Fernando Herrera
f5fcf9d635
Dataframe feature for plugins (#3424) 2021-05-13 21:49:46 +12:00
JT
9b8b1bad57
Don't insert PATH variable on Windows (#3422)
* Don't insert PATH variable on Windows

* Simplify fix

* Just centralize the var

* Add a message about why we have to workaround the issue
2021-05-13 15:03:49 +12:00
Sympatron GmbH
874ecd6c88
Made completion matching case-insensitive by default for windows (#3420) 2021-05-13 11:38:43 +12:00
Fernando Herrera
0905a2c3a2
commands to engine p (#3417)
* commands to engine p

* Clippy suggestion

* Clippy suggestion
2021-05-13 07:07:20 +12:00
JT
3aa00b78f9
Improve missing var in var-path error (#3415) 2021-05-12 20:53:34 +12:00
JT
6769d46dbb
Do less work in sys (#3413) 2021-05-12 17:24:22 +12:00
JT
efac712f62
Fix string interp/shorthand overlap (#3412) 2021-05-12 16:20:29 +12:00
JT
2bb23c57df
Bump to 0.31.1 (#3411) 2021-05-12 15:06:50 +12:00
Fernando Herrera
bc699a2cc1
date commands ported (#3410) 2021-05-12 14:01:49 +12:00
Fernando Herrera
758c128147
Config commands to engine p (#3408)
* config get command

* config remove command

* config set command

* config command

* config commands
2021-05-12 14:01:16 +12:00
Alex Shadley
3795c2a39d
Migrate last to engine-p (#3406)
* migrates last to engine-p

* removes unused import

* linter fix

* switch to as_usize()
2021-05-12 13:59:08 +12:00
JT
311c0e3f50
Simplify string interpolation (#3401)
* [DRAFT] simplify string interpolation

* Fix test
2021-05-12 13:53:57 +12:00
JT
25a8caa9b0
Simplify expressions (#3389)
* 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
Fernando Herrera
c80a9585b0
Complete Dataframe MVP (#3373)
* Dataframe MVP

* Removed test csv file

* Dataframe MVP

* Removed test csv file

* New revision polars

* New revision polars

* csv file reader

* argument parser for file reader

* Parser from Row primitive

* Column conversion

* Added as f32 and f64

* Parsing row to dataframe

* Removed repeated push to vector

* Accept table values to create dataframe

* Removed default serde

* Dataframe to rows to show data

* Save name of file with dataframe

* Usage example

* Upgrade polars version

* Clippy changes

* Added print function with head and tail

* Move dataframe struct to folder

* Lock file after running tests and merge

* Optional feature for dataframe

* Removed dataframe from plugins

* Update primitive.rs

Co-authored-by: JT <jonathandturner@users.noreply.github.com>
2021-05-12 13:01:31 +12:00
Darren Schroeder
e73491441a
make seq more nu-like by returning numbers when possible (#3409) 2021-05-11 12:02:16 -05:00
Nate Mara
b93b80ccaa
Remove unnecessary work from ps (#3407)
The ps plugin has an unnecessary call to `std:🧵:sleep(500ms)` that
delays runtime by 500ms. Additionally, there is a call to
`sysinfo::SystemExt::refresh_process`, which is not required as the previous
call to sysinfo::SystemExt::refresh_all handles the "refresh" of all processes
without a need to do this individually. Combining both of these improvements
means that running ps runs nearly instentaneously.

Fixes #3402
2021-05-11 19:59:24 +12:00
JT
48128c9db6
Bump to 0.31.0 (#3405) 2021-05-11 16:44:52 +12:00
Fernando Herrera
6dafaa197d
Commands to engine p (#3404)
* Change ansi command

* Change ansi strip command

* Change benchmark to engine-p

* ansi strip removed arg.process()

* benchmark without process args
2021-05-11 16:03:55 +12:00
Darren Schroeder
1634d8e087
add into string (#3403) 2021-05-10 12:58:51 -05:00
Jakub Žádník
7a583083b8
Convert the rest of "random" subcommands to engine-p (#3399)
* Convert "random bool" to engine-p

Also implements FromValue for Tagged<BigDecimal> and Tagged<f64>.

* Convert "random dice" to engine-p

* Convert "random uuid" to engine-p

* Covert "random chars" to engine-p

* Convert "random" command to engine-p
2021-05-10 19:07:57 +12:00
Michael Angerman
75156ab0c9
engine-p: build-string remove ActionStream (#3394) 2021-05-08 16:59:12 +12:00
Jakub Žádník
9fd6923821
Port random integer & decimal to engine-p + related refactoring (#3393)
* Implement minmax for Range; Simplify range command

* Port random integer to enginep; New FromValue impl

Now, FromValue is implemented for Tagged<Range> to allow extracting args
into this type.

* Make sure range value extraction fails properly

The range endpoint extraction methods now return error instead of
silently clipping the value. This now makes `random integer ..-4` fail
properly since -4 can't be cast as u64.

* Port random decimal to enginep & Refactor

This added a way to interpret Range limits as f64 and a Primitive helper
to get its value as f64.

A side effect of this commit is that it is now possible to specify the
command bounds as true decimals. E.g., `random decimal 0.0..3.14` does
not clip 3.14 to 3.
2021-05-08 07:58:12 +12:00
JT
91a929b2a9
Clippy fixes for new Rust version (#3392) 2021-05-07 07:58:21 +12:00
Javier Goday
bd71c2f34d
#3385: Add ignore-case and duplicated options to uniq command (#3387)
* #3385: Add ignore-case and duplicated options to uniq command

* rustfmt
2021-05-06 12:07:42 +12:00
onthebridgetonowhere
001123dbd6
Add first prototype of functionality to parse numbers in parantheses (#3209)
* Add first prototype of functionality to parse numbers in parantheses (). Needs testing and more wide-testing+integration

* Fix styling issue

* Try something else by copying existing matching code

* Fix formatting

* Fix the parser to accept numbers in paranthesis. Not really happy with the code, but let's see

* Refactor to only use once the parsing of strings into numbers

* Remove errors that are not used

* Fix formatting

Co-authored-by: Stefan Stanciulescu <contact@stefanstanciulescu.com>
2021-05-06 09:00:55 +12:00
ammkrn
cfee151d4e
Dont unwrap rustyline helper in cli (#3382)
If nu fails to load a user config on startup, no helper is set and the
later call to `rl.helper_mut()` will panic. There may be better ways to
handle this long-term, but printing an error about the failure to parse
the config and then starting with default values seems reasonable.
2021-05-04 15:50:38 +12:00
JT
fc59291191
Simplify down to one type of context (#3379)
* Simplify down to one type of context

* More simplification
2021-05-03 11:45:55 +12:00
Jakub Žádník
4fc05cac56
Port range to engine-p (#3377)
* Removes arg serialization
* action stream -> output stream
* uses nu_protocol::Range instead of NumericRange
* random missing newline I found in the code
2021-05-03 07:47:59 +12:00
Darren Schroeder
cc4616f25b
added check for endian-ness, added a bytes and skip (#3375) 2021-05-01 15:48:17 -05:00
Darren Schroeder
e82fbb7bcf
added ability to change "#" color using header_color (#3374) 2021-05-01 12:30:50 -05:00
Darren Schroeder
8cd639f6a2
add nu-pretty-hex, add into binary, update binaryview (#3370)
* add nu-pretty-hex, add into binary, update binaryview

* updated parameter name, updated examples

* fixed nu-pretty-hex test

* fixed tests again! and added a no color option to pretty-hex
2021-05-01 11:12:25 -05:00
Darren Schroeder
a8f555856a
tweaked the error handling to show specific errors (#3367) 2021-04-30 09:24:06 -05:00
Darren Schroeder
3792562046
updated to a quicker levenshtein implementation (#3366) 2021-04-29 07:10:10 -05:00
Leonhard Kipp
d05c48a1d7
Fix #3231: Pick up nu-env if cd with shortcuts (#3344)
* Fix autoenv not set when using implied cd

* Fix wrong return value

* Fix windows no value returned err
2021-04-28 17:31:22 +12:00
Jamie Quigley
36cc5eb933
Fix array index out of bounds error in nu_protocol::value::levenshtein_distance() (#3358)
* Fix array index out of bounds error.

Error occured when computing levenshtein_distance of two strings where
str.len() is not equal to str.chars().collect::<Vec<_>>().len()

* Add test for levenshtein_distance
2021-04-28 07:30:32 +12:00
Javier Goday
f9f74a0f7d
#3298: reduce --numbered bug (#3354) 2021-04-27 19:07:56 +12:00
Jakub Žádník
77f42931ff
Fix table-pager feature compilation (#3359)
It compiles and works without errors, but the pager is not asynchronous
anymore (i.e., you need to wait for `seq 1 1000000` to finish before the
pager is displayed).
2021-04-27 19:06:57 +12:00
Darren Schroeder
73f62266c6
allow start to handle urls (#3351) 2021-04-24 09:33:17 -05:00
ccde177b5fb9b8c55078417b4c9fee
df2f3d25b0
ichwh removed (#3349)
* ichwh removed

* removed unnecessary into() on PathBuf
2021-04-23 05:14:20 +12:00
JT
599c43ce04
bump to 0.30.1 (#3348) 2021-04-22 21:07:54 +12:00
Leonhard Kipp
5c2199e7f4
Move any to enginep style (#3324) 2021-04-22 20:35:45 +12:00
JT
3ad4e0348f
Fix external redirect (#3345)
* Fix external redirection

* Fix external redirection
2021-04-22 08:54:34 +12:00
JT
02d5729941
Properly evaluate dynamic blocks (#3339) 2021-04-21 14:31:54 +12:00
JT
ce35689d2e
Make finding the path variable more robust (#3336)
* Make finding the path variable more robust

* Update reload_config also
2021-04-21 11:37:10 +12:00
JT
da81e21bf2
Add a sync from the known path to the env (#3335) 2021-04-21 08:22:53 +12:00
Jakub Žádník
3b2ed7631f
Path Enhancement Project #2: parse, join and split (#3256)
* Add new path parse subcommand

This includes a slight refactor to all the path subcommand `action()`
functions.

* Remove filestem and extension; Fix example

* Add additional description to path parse

* Put join arg behind flag; Fix missing import (Win)

* Fix error when column path is passed as arg

* Add structured path joining

Structured path is implicitly joined at every patch subcommand call.

* Fix existing path join tests; Fix rustfmt

* Remove redundant 'static lifetime (clippy)

* Add initial impl of path split subcommand

* Add ability to join path from parts

* Fix wrong results in path split examples

* Fix remaining asyncs after engine change

* Do not wrap split path parts into table

When the input is just a list of values, the `path split` command will
split each value directly into the output stream, similar to
`split-row`. Column path--specified values are still wrapped into a
table so they can still be used to replace table fields.

* Join list of values instead of going one-by-one

When `path join` encounters a list of values, it attempts to join them,
instead of going one-by-one like the rest of the path commands. You can
still `each { echo $it | path join }` to join them one-by-one, if the
values are, e.g., tables.

Now, the behavior of `path split` and `path join` should match the
`split-row` and `str collect` counterparts and should hopefully align
better with user's expectations.

* Make sure path join detects structured path

* Fix panic on empty input stream

Also, doesn't collect input into vector unnecessarily.

* Fix path join not appending value

* Remove argument serialization

* Make better errors; Misc refactor

* OsStr -> String encoding is now lossy, instead of throwing an error
* The consequence is action() now always returns Value instead of Result
* Removed redundant handle_value() call in `path join`
* Fix possible incorrect error detection in `path split`
* Applied rustfmt + clippy

* Add more usage, examples & test; Fix type error

The 'parent' column was required to be a path but didn't work with
string.

* Add more help & examples; Maybe fix Windows error

* Refactor operate function

Reducing code repetition

* Review usages and examples

* Add the option to manually specify the extension

* Add more tests; Fix failures on Windows

* Move path commands to engine-p

* Small refactor
2021-04-20 18:45:28 +12:00
Leonhard Kipp
1a46e70dfb
Use new functions in which (#3310)
* Use new functions in which

* Impl rest_with_minimum and use it

* Use has_flag instead of get_switch
2021-04-20 18:38:36 +12:00
JT
0fc9b6cfa2
Bump to 0.30 (#3333)
* Bump to 0.30

* fix test
2021-04-20 18:34:10 +12:00
JT
61768aa2fd
Fix parsing dot dot path (#3331) 2021-04-20 08:18:29 +12:00
Darren Schroeder
ea5bf9db36
add query json plugin for experimentation (#3327)
* add query json plugin for experimentation

* add some error handling

* closer but Kind::Array is still horked

* unravel the table so the output looks right

* clippy

* added the ability to use gjson modifiers
2021-04-19 11:19:06 -05:00
JT
9d24afcfe3
Make nth more stream-able (#3330) 2021-04-19 19:45:12 +12:00
Leonhard Kipp
033df9457b
Engine-p style in compact (#3325)
* Engine-p style in compact

* Remove unused import

* Use filter in compact, thanks to clippy for spotting it :]
2021-04-19 06:40:29 +12:00
Leonhard Kipp
d8e105fe34
Enginep/all (#3312)
* Add iter-extensions

* Move all to enginep style

* Remove iter extensions

* Fix clippy lints

* Add comment and make ? more visible

* Remove try_all

* Remove all because it cant return err
2021-04-19 06:39:33 +12:00
Luccas Mateus
611103d211
Fix Running echo .. starts printing integers forever (#3322) 2021-04-16 07:07:06 +12:00
Darren Schroeder
528c1c5fd8
change $scope.variables output to a table (#3323) 2021-04-15 14:02:08 -05:00
JT
f73732bf1e
Move to* and from* to engine-p (#3320)
* WIP

* Finish last batch
2021-04-15 19:43:33 +12:00
Darren Schroeder
fd7875e572
sort scope.aliases, commands, variables (#3319) 2021-04-14 18:57:47 -05:00
Michael Nitschinger
e8bc319f08
Make sure that scripts can also have custom commands. (#3309)
With the current code it is possible to attach custom commands from
a custom binary, but only for interactive mode. This change makes
it possible to also customize the evaluation context for commands
and scripts.
2021-04-15 06:21:50 +12:00
Martin Mauch
a92ff57270
Use append_history instead of save_history to preserve existing history (#3314) 2021-04-15 06:20:25 +12:00
Luccas Mateus
004230d02d
Deserialization and outputstream math commands (#3315)
* Output error when ls into a file without permission

* math sqrt

* added test to check fails when ls into prohibited dir

* fix lint

* math sqrt with tests and doc

* trigger wasm build

* Update filesystem_shell.rs

* converted math commands to outputstream and new method for arg evaluation

* fmt

* clippy

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-04-15 06:18:37 +12:00
Darren Schroeder
a148c640b2
add variables to $scope (#3316) 2021-04-14 09:48:14 -05:00
Darren Schroeder
ea0205f2ff
remote --help/-h from $scope.commands display (#3311)
* remote --help/-h from $scope.commands

* change a test
2021-04-14 07:55:58 -05:00
Darren Schroeder
005649b6fc
remove dupes in get_commands/get_command_names (#3308) 2021-04-13 09:21:44 -05:00
Jonathan Turner
e09e3b01d6
Fix the auto-conversion regression (#3307) 2021-04-13 14:25:18 +12:00
Jonathan Turner
fc15e0e27d
A few optimisations (#3306)
* A few optimisations

* Fix test
2021-04-12 19:47:31 +12:00
Steven Barragán
b2fe5fabb1
Add commands to scope variable (#3272)
* Add commands to scope variable

* List commands with signature on scope variables

Usage:

```shell
echo $scope.commands | pivot
```

* Run rust formater

* Update variables.rs

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-04-12 14:38:47 +12:00
Leonhard Kipp
52d69bb021
Fix #3213 Rest arg is not optional (#3303) 2021-04-12 14:37:36 +12:00
Jonathan Turner
5f550a355b
Split OutputStream into ActionStream/OutputStream (#3304)
* Split OutputStream into ActionStream/OutputStream

* Fmt

* Missed update

* Cleanup helper names

* Fmt
2021-04-12 14:35:01 +12:00
Jakub Žádník
dbecbdccd4
Fix type error when Value is viewed as file path (#3305)
I believe this should be "path", not "string".
2021-04-12 11:53:31 +12:00
Jonathan Turner
734877338d
Remove take_while from internal iterator (#3301) 2021-04-11 18:29:01 +12:00
Jonathan Turner
2e439ca77f
Improve range and internal iteration (#3300) 2021-04-11 13:31:08 +12:00
Darren Schroeder
a853880e07
preparing for into subcommands (#3299) 2021-04-10 11:29:11 -05:00
Darren Schroeder
93f3ed98e1
clean up error handling a bit (#3297)
* clean up error handling a bit

* clippy
2021-04-10 10:10:23 -05:00
Andrés N. Robalino
a131eddf54
move out call info deserializing from str (#3294) 2021-04-09 22:58:18 -05:00
ammkrn
b19a7aa8a6
Disallow rm to trash if built without trash-support enabled. (#3278)
If built without `trash_support`, nu should explicitly reject attempts to use `rm` with the `--trash` option, or with a config file which includes `rm_always_trash = true`.

As of 42fac72, there doesn't seem to be any guard in the `#[cfg(not(feature = "trash-support"))]` block of `filesystem_shell::rm`, leading to the behavior described in #3116, where builds without the trash-support feature will delete things permanently regardless of flags/config options.

This should close #3116
2021-04-10 14:01:21 +12:00
Jonathan Turner
f5aa53c530
Remove length collecting its input (#3292)
* Remove length collecting its input

* Update length.rs
2021-04-10 10:21:51 +12:00
Darren Schroeder
80f5e14512
Fix ansi rgb fg (#3293)
* add term size command

* bug: fix ansi rgb_fg
2021-04-09 15:32:25 -05:00
Darren Schroeder
0b5e131410
Remove x1b, update prompt (#3291)
* add term size command

* remove \x1b and use nu_ansi_term, make prompt with no config prettier
2021-04-09 11:38:56 -05:00
Eli Flanagan
556596bce8
add "into int" behavior (#3279)
* add 'int' command

* create `into int` behavior

- forcibly overwrote prior implementation

```sh
git mv -f  crates/nu-command/src/commands/int_.rs crates/nu-command/src/commands/into_int.rs
```
- picked up prior work, polished and renamed

Co-authored-by: Saeed Rasooli <saeed.gnu@gmail.com>
2021-04-09 09:17:39 -05:00
Jonathan Turner
b791d1ab0d
Move from using a Block to an Arc'd Block (#3289) 2021-04-09 20:12:25 +12:00
Leonhard Kipp
ac070ae942
Refactor/config commands (#3265)
* Use ctx.configs in all config commands

* Remove all setting/accessing of  vars.("config-path")

* Add tests

* Add comment

* Reload cfg on remove

* Hypocratic ws change

* Use history_path in hist_or_default

* Make clippy happy

* Fix rebase stuff

* Fix clippy lint
2021-04-09 18:03:12 +12:00
Marc Schreiber
111ad868a7
Do not store whitespace entries into history (#3019) (#3286)
Before storing an entry into the history nushell will check if the entry
consists only of whitespaces and if so, it does not store it in the history and
this avoids  newline repetition when user is navigating in the history.
2021-04-09 12:01:31 +12:00
Andrés N. Robalino
a7274115d0
make Table, Autoview read in memory config. (#3287) 2021-04-08 17:31:19 -05:00
Jonathan Turner
81160bcefb
Remove some clones and improve when autoview reads config (#3285) 2021-04-09 07:47:41 +12:00
Andrés N. Robalino
2880109f31
Runnable contexts move. (#3283)
* Engine extract first steps.

* Don't depend on ShellManager.
2021-04-08 13:51:12 -05:00
Jonathan Turner
09a1f5acb9
Begin migration away from arg serialization (#3281)
* initial implementation

* Move a few commands over to new arg system

* Fix char also
2021-04-08 20:15:36 +12:00
Jonathan Turner
5fcf11fcb0
Fix externals busy waiting (#3280) 2021-04-08 07:25:15 +12:00
Jonathan Turner
42fac722bb
Bump to 0.29.2 (#3274)
* Bump to 0.29.2

* Fix test
2021-04-07 08:14:06 +12:00
Jonathan Turner
073e5727c6
Switch to "engine-p" (#3270)
* WIP

* WIP

* first builds

* Tests pass
2021-04-06 11:19:43 -05:00
ChroniCat
ad1c4f5e39
[fix] crashing issues when the given timestamp is out of range (#3271)
* add support for timestamp-based time conversion by specifing timezone or 'UTC/Local'

* [fix] fix the wrong test sample

* code formating

* code formating and import missing mod to test

* code formating again

* [fix] it won't crash when given timestamp is too big.

* [fix] code formatting =_=b
2021-04-06 07:22:07 -05:00
Darren Schroeder
dc8a68c98f
Bump sysinfo (#3267)
* add term size command

* update to the latest sysinfo
2021-04-05 14:36:19 -05:00
Mohammed Anas
e5621dea58
Remove yr and mon (#3262)
* Remove `yr` and `mon`

* Remove usage of mon in test

* Fix test
2021-04-05 06:19:33 +12:00
Andrés N. Robalino
00acf22f5f
account for startup commands in the scope. (#3261)
* Revert "Impl one configurable function to run scripts (#3242)"
* pass config startup.
2021-04-04 00:14:58 -05:00
Saeed Rasooli
4c09716ad8
add TiB and PiB (#3257) 2021-04-04 12:08:17 +12:00
Andrés N. Robalino
1c941557c3
Remove unused help shell. Slight cleanup and improvement. (#3258) 2021-04-03 18:56:46 -05:00
Leonhard Kipp
28e1a7915d
Impl one configurable function to run scripts (#3242)
* Impl one func to run scripts

* Add exit_on_err

* Remove run_standalone

* Make the compiler happy :)
2021-04-04 07:31:53 +12:00
Waldir Pimenta
4bc9d9fd3b
Fix typos and capitalization of "Unicode" (#3234)
* Capitalize "Unicode"

* Fix several typos

* Fix mixed whitespace in nu-parser's tests
2021-04-04 07:14:07 +12:00
Andrés N. Robalino
e278ca61d1
commands: any? all? (#3252)
* commands: any? all?

We can check if `any` (or `all`) rows of tables match predicates.

Small `all?` example: Given the following table with `services` running:

```
> echo [[status]; [UP] [UP]]
───┬────────
 # │ status
───┼────────
 0 │ UP
 1 │ UP
───┴────────
```

We can ask if all services are UP, like so:

```
> echo [[status]; [UP] [UP]] | all? status == UP
true
```

* Fix any? signature.
2021-04-03 13:40:54 -05:00
Luccas Mateus
2146ede15d
Parse decimal units (#3243)
* parse decimal units

* linting

* stop clippy complaining

* Added tests to parsing decimals

* Fixed bug

* Fixed testing and add more
2021-04-03 21:06:13 +13:00
Saeed Rasooli
e737222a5d
fix lack of auto-suggestion for aliases (#3249) 2021-04-03 10:39:30 +13:00
Leonhard Kipp
f03f1949bf
Logs and tests (#3247)
* Add command name to err

* Add var name to error message

* Add test for def comment in test
2021-04-01 17:09:33 -05:00
Luccas Mateus
0fe6c7c558
Mathsqrt (#3239)
* Output error when ls into a file without permission

* math sqrt

* added test to check fails when ls into prohibited dir

* fix lint

* math sqrt with tests and doc

* trigger wasm build

* Update filesystem_shell.rs

* always forgetting the linting

* fix clippy complaining

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-04-01 16:26:05 -05:00
Leonhard Kipp
b13202bbfc
Fix #3244: Add tag reloaded frame (#3246) 2021-04-01 16:25:26 -05:00
Luccas Mateus
90fae903ce
Fixes error when trying to delete a FIFO (#3235)
* Output error when ls into a file without permission

* added test to check fails when ls into prohibited dir

* fix lint

* trigger wasm build

* be able to remove fifos

* Update filesystem_shell.rs

* I thought windows had fifos

* fixed unix and windows conditional compilation

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-04-01 06:10:40 +13:00
Jonathan Turner
06b154f4b2
Bump to 0.29.1 (#3232)
* Bump to 0.29.1

* fix test
2021-03-31 20:13:40 +13:00
Luccas Mateus
419a0665c8
Output error when ls into a file without permission (#3218)
* Output error when ls into a file without permission

* added test to check fails when ls into prohibited dir

* fix lint

* trigger wasm build

* Update filesystem_shell.rs

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-03-31 19:52:39 +13:00
Luccas Mateus
387098fc87
Stop nu panicks in math.round on a large decimal value(Most of the time) (#3224)
* Stop crashing when dealing with large numbers in math round

* Fix formatting

* add tests

* just to trigger wasm build

* trigger wasm build
2021-03-31 19:01:39 +13:00
Leonhard Kipp
c42b588782
Refactor nu-cli/env* (#3041)
* Revert "History, more test coverage improvements, and refactorings. (#3217)"

This reverts commit 8fc8fc89aa.

* Add tests

* Refactor .nu-env

* Change logic of Config write to logic of read()

* Fix reload always appends to old vars

* Fix reload always takes last_modified of global config

* Add reload_config in evaluation context

* Reload config after writing to it in cfg set / cfg set_into

* Add --no-history to cli options

* Use --no-history in tests

* Add comment about maybe_print_errors

* Get ctrl_exit var from context.global_config

* Use context.global_config in command "config"

* Add Readme in engine how env vars are now handled

* Update docs from autoenv command

* Move history_path from engine to nu_data

* Move load history out of if

* No let before return

* Add import for indexmap
2021-03-31 18:52:34 +13:00
Jonathan Turner
4faaa5310e
Bump to 0.29 (#3230)
* Bump to 0.29

* fix test
2021-03-30 22:35:21 +13:00
Michael Angerman
c448abd44e
echo $scope.aliases | pivot to see all of your aliases (#3203)
* enable ability to see all aliases, pull in code from scope branch

* add in the alias tests

* add back in my changes to variables.rs after merging in andrasios changes from PR #3217
2021-03-29 21:27:51 +13:00
Darren Schroeder
2517588d7d
update date to-timezone usage (#3223) 2021-03-28 18:41:42 -05:00
Andrés N. Robalino
8fc8fc89aa
History, more test coverage improvements, and refactorings. (#3217)
Improvements overall to Nu. Also among the changes here, we can also be more confident towards incorporating `3041`. End to end tests for checking envs properly exported to externals is not added here (since it's in the other PR)

A few things added in this PR (probably forgetting some too)

* no writes happen to history during test runs.
* environment syncing end to end coverage added.
* clean up / refactorings few areas.
* testing API for finer control (can write tests passing more than one pipeline)
* can pass environment variables in tests that nu will inherit when running.

* No longer needed.

* no longer under a module. No need to use super.
2021-03-27 00:08:03 -05:00
Mark Volkmann
b243b3ee1d
fixed typo in help text (#3216) 2021-03-26 08:11:41 -05:00
Darren Schroeder
28e08afada
add ability to cd to ~/blah (#3210)
* add ability to cd to ~/blah. tested on windows.

* added dirs_next

* put change behind feature for linux-minimal/wasm

* clippy

* holy crap minimal, i'm about done with you!
2021-03-26 22:29:02 +13:00
Jonathan Turner
7e184b58b2
Fix warnings for Rust 1.51 (#3214)
* Fix warnings for Rust 1.51

* More fixes

* More fixes
2021-03-26 21:26:57 +13:00
ChroniCat
589fc0b8ad
add support for timestamp-based time conversion by specifying timezone (#3207)
* add support for timestamp-based time conversion by specifing timezone or 'UTC/Local'

* [fix] fix the wrong test sample

* code formating

* code formating and import missing mod to test

* code formating again
2021-03-24 08:08:23 -05:00
ahkrr
f0c7c1b500
fix: prompt does not find external commands #3134 (#3189)
the initial setup-commands of nushell were executed without loading environment variables
this resulted in the PATH not being available at this point until an external command was run once
which resulted in env_vars being added
let run_result = run_block(&prompt_block, &context, InputStream::empty()).await;

Co-authored-by: alexhk <alexhk@protonmail.com>
2021-03-23 22:38:07 +13:00
Naftali Goldstein
840bd98e01
support forward slash for directory completion in Windows (#3201)
While the "main" separator in Windows is the backslash, it supports the
forward slash as a separator too.
Add support for this so that the behavior is similar to the way Windows
PowerShell handles the forward slash: it is recognized as a separator,
and when using <tab> for path completion the slash is reversed.
2021-03-23 16:20:01 +13:00
Ryan Blecher
a5cdd22bfe
Add basic support for md5 hashing strings and binary data (#3197) 2021-03-21 07:48:53 +13:00
Darren Schroeder
ab666c170c
added the ability to create multi-byte unicode chars like emoji (#3195) 2021-03-18 13:42:39 -05:00
Andrés N. Robalino
d2213d18fa
Playground infraestructure (tests, etc) additions. (#3179)
* Playground infraestructure (tests, etc) additions.

A few things to note:

* Nu can be started with a custom configuration file (`nu --config-file /path/to/sample_config.toml`). Useful for mocking the configuration on test runs.
* When given a custom configuration file Nu will save any changes to the file supplied appropiately.
* The `$nu.config-path` variable either shows the default configuration file (or the custom one, if given)
* We can now run end to end tests with finer grained control (currently, since this is baseline work, standard out) This will allow to check things like exit status, assert the contents with a format, etc)

* Remove (for another PR)
2021-03-15 02:26:30 -05:00
nibon7
82b6300dcb
fix: cargo test failed with --release (#3183) (#3184)
Signed-off-by: nibon7 <nibon7@163.com>
2021-03-15 16:59:04 +13:00
Warren Seine
b69cda9e07
Add --signal option to kill command (#3077) (#3079) 2021-03-15 13:10:52 +13:00
ahkrr
56adc7c3c6
imp: bump rustyline to 8.0.0 (#3167)
* imp: bump rustyline to 8.0.0

* fix: rustyline 8 keybindings

* fix: commands count/length test

Co-authored-by: alexhk <alexhk@protonmail.com>
2021-03-14 15:13:31 +13:00
Kenneth Cochran
2ace20fade
Make opening a directory list its contents (#3118)
* Make opening a directory enter it.

Not sure if this change is wanted, but I'm not sure what else opening a directory could mean.
And I find myself accidentally using `open <dir>` to mean `enter <dir>`

* Add example to open directory

* Open dir should list it's contents

* Update example description and fix style
2021-03-14 10:47:31 +13:00
John-Goff
c13fe83784
Rename count to length (#3166)
* update docs to refer to length instead of count

* rename count to length

* change all occurrences of 'count' to 'length' in tests

* format length command
2021-03-14 10:46:40 +13:00
Leonhard Kipp
6cf8df8685
Move script to nu engine (#3092)
* Move run_script to engine

* Add which dep and feature to engine

* Change unwrap to expect

* Add wasm specification

* Remove which from default, add specification correctly

* Add nu-platform-specifics

* Move is_external_cmd to platform_specifics

* Add is_external_cmd to host and use it instead of nu_platform directly

* Clean up if else logic in is_external_cmd

* Bump nu-platform-specifics version

* Pass context to print_err

* Commit cargo.lock

* Move print functions to own module inside nu-engine

* Hypocratic change to run windows-nightly again

* Add import for Ordering

* Move printing of error to host

* Move platform specific which functionality to basic host

* Allow no use of cmd_name

* Fix windows compile issue
2021-03-12 18:20:54 +13:00
ahkrr
86a89404be
fix: unicode byte counting error #3150 (#3159)
Co-authored-by: hk <alexhaka10@protonmail.com>
2021-03-12 07:11:07 +13:00
Jonathan Turner
0d305d7c3e
Lines no longer treats a text buffer as a line (#3153) 2021-03-11 11:35:15 +13:00
Darren Schroeder
ee5bd2b4b3
move from h1-client-rustls to hyper-client (#3154) 2021-03-10 15:45:53 -06:00
Jonathan Turner
22ae962b57
Bump to 0.28 (#3149) 2021-03-09 23:40:17 +13:00
Darren Schroeder
864139d67f
move bel and backspace to char since they're not ansi (#3144)
* move bel and backspace to char since they're not ansi

* Trigger Build
2021-03-09 22:34:51 +13:00
Tw
1dc7e00d20
Fix trash functionality (#3146)
For now the trash doesn't work because the trash-support flag isn't enabled in nu-engine
crate, so make it work by adding this flag.

Signed-off-by: Tw <wei.tan@intel.com>

Co-authored-by: Tw <wei.tan@intel.com>
2021-03-09 22:34:14 +13:00
Jakub Žádník
49a9107e0f
Allow composing help message from two parts (#3124)
* Split help message into brief and full help

Demonstrate on ansi command

Brief help is printed when running `help commands` so it doesn't clutter
the table. Full help is printed when normal help message is requested
(e.g., `help ansi`, `ansi --help`, etc.).

* Split long command descriptions

Some are not split, just edited to be shorter.

* Capitalize the usage of all commands

* Make sure every usage ends with dot

* Fix random typo
2021-03-08 12:57:58 +13:00
ahkrr
7b8c2c232f
fix: deadlock when printing errors (#3140)
Co-authored-by: hk <alexhaka10@protonmail.com>
2021-03-08 12:08:37 +13:00
Darren Schroeder
15e1e6376b
remove warnings (#3137) 2021-03-06 14:31:22 -06:00
rezural
06d9d9ed08
use minus v3.3.0 (#3136) 2021-03-07 06:47:01 +13:00
rezural
74e10d6f72
print string returned by draw_table, in autoview when pivot mode is on (#3135) 2021-03-06 10:17:37 -05:00
Tiffany Bennett
d43489a6a0
Add exit code argument (#3132) 2021-03-06 18:46:27 +13:00
Darren Schroeder
983de8974b
hopefully fixes the coercion error when comparing $nothing to $var (#3133) 2021-03-05 14:07:54 -06:00
rezural
c91a1ec08d
Table paging release (#3128)
* use the InputHandler functionality from minus

* respond to Q and ESC character to quit

* use arijit79/minus main branch until new release is pushed

* rename NushellMinusInputHandler to MinusInputHandler
2021-03-05 10:32:16 +13:00
Darren Schroeder
507de45d40
Revert "add config: prompt_color_enabled = true (#3115)" (#3127)
This reverts commit fe0fc8d5e1.
2021-03-04 12:22:14 -05:00
Saeed Rasooli
fe0fc8d5e1
add config: prompt_color_enabled = true (#3115) 2021-03-04 20:08:26 +13:00
rezural
e4a8db56f9
use add_exit_callback, update to rezural/nushell which contains add_exit_callback, and contains updated keybindings (#3121) 2021-03-04 20:06:22 +13:00
Jakub Žádník
1d1ec4727a
Refactor arguments of path subcommands & Add path join subcommand (#3123)
* Refactor path subcommand argument handling

DefaultArguments are no longer passed to each subcommand. Instead, each
subcommand has its own Path<xxx>Arguments. This means that it is no
longer necessary to edit every single path subcommand source file when
changing the arguments struct.

* Add new path join subcommand

Makes it easier to create new paths. It's just a wrapper around Rust's
Path.join().
2021-03-04 20:04:56 +13:00
Andrés N. Robalino
0b71e45072
Preserve order when serializing/deserialize json by default. (#3126) 2021-03-04 01:35:13 -05:00
Darren Schroeder
9c375b33a6
updated fetch to surf2.2 and feature h1-client-rustls (#3120) 2021-03-04 07:18:11 +13:00
Jakub Žádník
28a6a5ea57
Add option to invert match command selection (#3114)
* Add option to invert match command selection

* Fix rustfmt error

* Rename match --exclude to --invert

To be more descriptive and conform to e.g. grep or ripgrep -v flag.
Also simplified the --invert flag description.

* Fix formatting when description got shorter

Co-authored-by: Jakub Žádník <jakub.zadnik@tuni.fi>
2021-03-02 06:48:22 +13:00
Leonhard Kipp
f83ff0e47d
Use writer from host instead of always std::err (#3112) 2021-03-01 15:00:40 +13:00
rezural
079e575cac
Table paging (Draft PR) (#3058)
* This adds table paging, relying on minus to perform the paging functionality
This is gated behind the table-pager feature

* fix problem with long running InputStreams blocking table() returning

* some comments regarding Arc clones, and callback from minus
2021-03-01 14:59:33 +13:00
Michael Angerman
6b2327f231
help generate_docs | flatten crashes nushell (#3099)
* fix case where parent_name was {nu, term} and possibly others in the future by doing an extra test first to see if if the *parent_name key actually exists in cmap

* update with help generate_docs testing
2021-02-27 09:05:22 +13:00
Saeed Rasooli
596608aa0c
nu_plugin_match: accept -i -m -s flags (#3111) 2021-02-27 07:41:22 +13:00
Saeed Rasooli
120e80d1b6
refactor parse_math_expression, reduce indentation (#3093) 2021-02-26 18:11:20 +13:00
Jonathan Turner
aa6c6120f6
Bump to 0.27.2 (#3109)
* Bump to 0.27.2

* Fix clippy and test
2021-02-26 17:55:25 +13:00
Andrés N. Robalino
19d5f782cc
Allow dropping columns. (#3107)
`drop` is used for removing the last row. Passing a number allows dropping N rows.
Here we introduce the same logic for dropping columns instead.

You can certainly remove columns by using `reject`, however, there could be cases
where we are interested in removing columns from tables that contain, say, a big
number of columns. Using `reject` becomes impractical, especially when you don't
care about the column names that could either be known or not known when exploring
tables.

```
> echo [[lib, extension]; [nu-core, rs] [rake, rb]]
─────────┬───────────
   lib   │ extension
─────────┼───────────
 nu-core │ rs
 rake    │ rb
─────────┴───────────
```

```
> echo [[lib, extension]; [nu-core, rs] [rake, rb]] | drop column
─────────
   lib
─────────
 nu-core
 rake
─────────
```
2021-02-25 15:37:21 -05:00
Darren Schroeder
dfe95d3ae6
enabled the easy access use of nu-ansi-term's "Light" colors (#3100) 2021-02-24 15:36:22 -06:00
Darren Schroeder
57ebec385f
add ansi strip subcommand (#3095)
* add ansi subcommand

* changed example test, added additional test
2021-02-23 14:16:13 -06:00
Andrés N. Robalino
7a77910720
Table content rolling. (#3097)
There are many use cases. Here we introduce the following:

- The rows can be rolled `... | roll` (up) or `... | roll down`
- Columns can be rolled too (the default is on the `left`, you can pass `... | roll column --opposite` to roll in the other direction)
- You can `roll` the cells of a table and keeping the header names in the same order (`... | roll column --cells-only`)
- Above examples can also be passed (Ex. `... | roll down 3`) a number to tell how many places to roll.

Basic working example with rolling columns:

```
> echo '00000100'
| split chars
| each { str to-int }
| rotate counter-clockwise _
| reject _
| rename bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8

───┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────
 # │ bit1 │ bit2 │ bit3 │ bit4 │ bit5 │ bit6 │ bit7 │ bit8
───┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────
 0 │    0 │    0 │    0 │    0 │    0 │    1 │    0 │    0
───┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────
```

We want to "shift" three bits to the left of the bitstring (four in decimal), let's try it:

```
> echo '00000100'
| split chars
| each { str to-int }
| rotate counter-clockwise _
| reject _
| rename bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
| roll column 3

───┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────
 # │ bit4 │ bit5 │ bit6 │ bit7 │ bit8 │ bit1 │ bit2 │ bit3
───┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────
 0 │    0 │    0 │    1 │    0 │    0 │    0 │    0 │    0
───┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────
```

The tables was rolled correctly (32 in decimal, for above bitstring). However, the *last three header names* look confusing.
We can roll the cell contents only to fix it.

```
> echo '00000100'
| split chars
| each { str to-int }
| rotate counter-clockwise _
| reject _
| rename bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
| roll column 3 --cells-only

───┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────
 # │ bit1 │ bit2 │ bit3 │ bit4 │ bit5 │ bit6 │ bit7 │ bit8
───┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────
 0 │    0 │    0 │    1 │    0 │    0 │    0 │    0 │    0
───┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────
```

There we go. Let's compute it's decimal value now (should be 32)

```
> echo '00000100'
| split chars
| each { str to-int }
| rotate counter-clockwise _
| reject _
| roll column 3 --cells-only
| pivot bit --ignore-titles
| get bit
| reverse
| each --numbered { = $it.item * (2 ** $it.index) }
| math sum

32
```
2021-02-23 13:29:07 -05:00
rezural
23d8dc959c
return string from draw_table instead of printing directly (#3088) 2021-02-23 22:25:49 +13:00
Kenneth Cochran
7f303a856e
Make sure CurDir is filtered out in absolutize. (#3084)
* Make sure `CurDir` is filtered out in absolutize.

Closes #3083

* Add test

* Make sure test works on windows
2021-02-23 22:22:17 +13:00
Michael Angerman
e834e617f3
Remove parking_lot crate reference from nu-data (#3091)
* remove parking_lot crate from nu-data as it is no longer being used

* remove commented out code from parse.rs

* remove commented out code from scope.rs
2021-02-23 22:21:31 +13:00
Darren Schroeder
2c89a228d5
add nu-ansi-term (#3089) 2021-02-22 12:33:34 -06:00
Andrés N. Robalino
803826cdcd
90 degree table rotations (clockwise and counter-clockwise) (#3086)
Also for 180 degree is expected. Rotation is not exactly like pivoting (transposing)
for instance, given the following table:

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]]
───┬───────┬───────┬───────
 # │ col1  │ col2  │ col3
───┼───────┼───────┼───────
 0 │ cell1 │ cell2 │ cell3
 1 │ cell4 │ cell5 │ cell6
───┴───────┴───────┴───────
```

To rotate it counter clockwise by 90 degrees, we can resort to first transposing (`pivot`)
them adding a new column (preferably integers), sort by that column from highest to lowest,
then remove the column and we have a counter clockwise rotation.

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | pivot | each --numbered { = $it.item | insert idx $it.index } | sort-by idx | reverse | reject idx
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

Which we can get easily, in this case, by doing:

```
> echo [[col1, col2, cel3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | rotate counter-clockwise
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

There are also many powerful use cases with rotation, it makes a breeze creating tables with many columns, say:

```
echo 0..12 | rotate counter-clockwise | reject Column0
───┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬──────────
 # │ Column1 │ Column2 │ Column3 │ Column4 │ Column5 │ Column6 │ Column7 │ Column8 │ Column9 │ Column10 │ Column11 │ Column12 │ Column13
───┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼──────────
 0 │       0 │       1 │       2 │       3 │       4 │       5 │       6 │       7 │       8 │        9 │       10 │       11 │       12
───┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴──────────
```
2021-02-22 06:56:34 -05:00
Saeed Rasooli
42d18d2294
add "-0" as short for --headerless in "from" commands (#3042)
* replace --headerless flags with --noheaders / -n

* Update from_csv.rs

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-02-22 20:25:17 +13:00
Darren Schroeder
b5ae024cc8
add the ability to time commands (#3081) 2021-02-20 07:37:14 -06:00
Michael Angerman
fc59c87606
this example now runs out of the box instead of failing with no value or the wrong value (#3067) 2021-02-19 21:40:53 +13:00
Andrés N. Robalino
7dc1d6a350
Extract .nu-env tests and more granularity (#3078)
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
Jonathan Turner
deff1aa63b
Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
Andrés N. Robalino
08e7d0dfb6
Keep the environment properly set. (#3072)
* Revert "fix prompts on startup (#3056)"

This reverts commit b202951c1d.

* Ensure environment variables synced with global internal Nu Scope.
2021-02-18 15:56:14 +13:00
rezural
892aae267d
add height method to Host trait, and implementors (#3064) 2021-02-17 09:02:13 +13:00
Darren Schroeder
11a9144e84
update mock table for easier table testing (#3065) 2021-02-17 04:47:47 +13:00
Jonathan Turner
039f223b53
Bump to 0.27 (#3063) 2021-02-16 19:20:05 +13:00
Jonathan Turner
e1cb026184
Add back in column truncation (#3061) 2021-02-16 07:15:16 +13:00
WatsonThink
0795d56c1c
Source path including tilda (#3059)
* Use expand_path to handle the path including tilda

* Publish path::expand_path for using in nu-command

* cargo fmt

Co-authored-by: Wataru Yamaguchi <nagisamark2@gmail.com>
2021-02-15 21:41:49 +13:00
Jonathan Turner
48a90fea70
Fix let-env (#3057) 2021-02-15 20:58:51 +13:00
Jonathan Turner
b202951c1d
fix prompts on startup (#3056)
* fix prompts on startup

* Try again
2021-02-15 20:14:16 +13:00
Saeed Rasooli
c3d2c61729
nu-parser: fix parsing comments with unclosed ' " [] {} in functions (#3053)
* nu-parser: fix parsing comments with unclosed ' " [] {} in functions

* add tests for last commit
2021-02-14 21:40:28 +13:00
Darren Schroeder
991ac6eb77
change help text (#3054) 2021-02-13 13:20:34 -06:00
Michael Angerman
011b7c4a07
refactor parser: rename method pub fn block to parse_block (#3047)
* refactor parser: rename method block to parse_block

* nu-cli/src/completion/engine.rs block to parse_block
2021-02-13 09:31:11 +13:00
Saeed Rasooli
617341f8d5
nu-engine: deserialize_struct: fix missing conversion from string to column path (#3048) 2021-02-13 09:29:38 +13:00
Jonathan Turner
5481db4079
Fix latest clippy warnings (#3049) 2021-02-12 23:13:14 +13:00
Saeed Rasooli
041086d22a
add config "filesize_metric = true" for default formatting of filesize (#3045) 2021-02-11 21:52:34 +13:00
ammkrn
aa564f5072
display boolean config options as true/false instead of Yes/No (#3043) 2021-02-11 21:50:33 +13:00
Darren Schroeder
1cfb228924
New termsize command (#3038)
* add term size command

* update w & h, add examples

* changed default to output table
2021-02-10 08:58:22 -06:00
Saeed Rasooli
b403fb1275
nu-parser + nu-protocol: switch to metric for KB, MB, GB, add KiB, MiB, GiB units (#3035)
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
Saeed Rasooli
7f7e8465da
Fix fmt and small cleaning in nu-parser (#3033)
* parse_unit: reduce indentation in loop

* fix fmt: crates/nu-parser/src/lex/tests.rs
2021-02-09 17:46:10 +13:00
Saeed Rasooli
233161d56e
sort_by: support -r flag for reverse (#3025)
* sort_by: support -r flag for reverse

* Update sort_by.rs

Fix reverse test

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2021-02-08 11:10:06 +13:00
Saeed Rasooli
d883ab250a
which: accept several applications/commands (#3024)
* which: accept several applications

* fix fmt: which_.rs
2021-02-08 08:17:06 +13:00
Leonhard Kipp
ef4e3f907c
parser/refactor def (#2986)
* Move tests into own file

* Move data structs to own file

* Move functions parsing 1 Token (primitives) into own file

* Rename param_flag_list to signature

* Add tests

* Fix clippy lint

* Change imports to new lexer structure
2021-02-08 08:10:14 +13:00
Andrés N. Robalino
debeadbf3f
Soft rest arguments column path cohersions. (#3016) 2021-02-06 20:05:47 -05:00
Qwanve
d66baaceb9
Fix 'ps -l' output when a process doesn't have a parent process. (#3015)
Before, ps would not insert a value if the process didn't have a parent.
Now, ps will insert an empty cell. This caused broken tables as some
rows didn't have all the columns.
2021-02-06 22:41:08 +13:00
Andrés N. Robalino
a5fefaf78b
Ensure selection of columns are done once per column (#3012) 2021-02-05 19:34:26 -05:00
Jonathan Turner
6f17662a4e
Update some deps (#3011) 2021-02-06 09:54:54 +13:00