* 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.
* 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
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.
* 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.
* 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
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>
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)`).
* 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>
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
* 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
* 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.
* 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>
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.
* Removes arg serialization
* action stream -> output stream
* uses nu_protocol::Range instead of NumericRange
* random missing newline I found in the code
* 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
* 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
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).
* 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
* 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
* 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
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.