Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.
Maybe it's just me, but I feel like the first should never change what's on the line; it's just a means to see possible options.
Fixes #7886.
/home/gabriel/CodingProjects/nushell〉'A|B|C' | parse -r '(\w)\|(\w)\|(\w)' 01/29/2023 01:08:29 PM
╭───┬──────────┬──────────┬──────────╮
│ # │ capture0 │ capture1 │ capture2 │
├───┼──────────┼──────────┼──────────┤
│ 0 │ A │ B │ C │
╰───┴──────────┴──────────┴──────────╯
Columns automatically named by parse -r
are now 0-indexec and uncapitalised.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Remove 🆖 comments (#7877)
Noticed several instances of commented out code that should just be
deleted. Also a comment on eval_external
that was incorrect. All gone
now.
Clean up cd.rs
(#7876)
Some general cleanup of cd.rs
; the permission checking code was a
little hard to follow. Reworded comments and variable names,
reorganized+renamed the module used for Unix file permissions.
Add 'number' command for enumeration (#7871)
This adds a number
command that will enumerate the input, and add an
index
and item
record for each item. The index
is the number of
the item in the input stream, and item
is the original value of the
item.
> ls | number | get 14
╭───────┬────────────────────────────╮
│ index │ 14 │
│ │ ╭──────────┬─────────────╮ │
│ item │ │ name │ crates │ │
│ │ │ type │ dir │ │
│ │ │ size │ 832 B │ │
│ │ │ modified │ 2 weeks ago │ │
│ │ ╰──────────┴─────────────╯ │
╰───────┴────────────────────────────╯
This adds a number
command.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Expose filtering by file type in glob (#7834)
Add flags for filtering the output of glob
by file type. I find myself
occasionally wanting to do this, and getting a file's
file_type
is presumably fast to do as it doesn't have to go through the fallible
metadata method.
The design of the signature does concern me; it's not as readable as a
filter or "include" type list would be. They have to be filtered one by
one, which can be annoying if you only want files -D -S
, or only want
folders -F -S
, or only want symlinks --butwhy?
. I considered
SyntaxShape::Keyword for this but I'll just defer to comments on this PR
if they pop up.
I'd also like to bring up performance since including these flags
technically incurs a .filter
penalty on all glob calls, which could be
optimized out if we added a branch for the no-filters case. But in
reality I'd expect the file system to be the bottleneck and the flags to
be pretty branch predictor friendly, so eh
Three new flags when using glob
and a slightly more cluttered help
page. No breaking changes, I hope.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
refactor: use input_handler::operate
in ansi_strip command (#7888)
While investigating do --ignore-errors
issue, just found that
ansi_strip
command using a custom operate
function(which is not
needed), this pr is just a refactor
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Fix wrong VarId of $in variable (#7893)
Fixes https://github.com/nushell/nushell/issues/7872
Fix panic when assigning value to $env (#7894)
Support extended unicode escapes in strings: "\u{10fff}" (#7883)
Support extended unicode escapes in strings with same syntax as Rust:
"\u{6e}"
.
New syntax in string literals, \u{NNNNNN}
, to go along with the
existing \uNNNN
.
New syntax accepts 1-6 hex digits and rejects values greater than
0x10FFFF (max Unicode char)..
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Won't break existing scripts, since this is new syntax.
We might consider deprecating char -u
, since users can now embed
unicode chars > 0xFFFF with the new escape.
Several unit tests and one integration test added.
cargo fmt --all -- --check
to check standard code formatting
(cargo fmt --all
applies these changes)
Donecargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
style
Donecargo test --workspace
to check that all tests passName threads (#7879)
I noticed that it's pretty easy to name threads in Rust. We might as well do this; it's a nice quality of life improvement when you're profiling something and the developers took the time to give threads names.
Also added/cleaned up some comments while I was in the area.
Re-enable some good tests, remove some bad tests (#7875)
I tackled some of the disabled FIXME
/#[ignore]
tests. Most were
straightforward to re-enable, and a few of them did not deserve to be
re-enabled.
Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com
Add Github Actions workflow to check for typos (#7892)
mention do
in complete
command's doc (#7884)
Closes: #7841
new complete doc:
Complete the external piped in, collecting outputs and exit code
To collect stderr messages and exit_code, external piped in need to wrapped with `do`
Usage:
> complete
Flags:
-h, --help - Display the help message for this command
Signatures:
<any> | complete -> <record>
Examples:
Run the external completion
> ^external arg1 | complete
Run external completion, collects stderr and exit_code
> do { ^external arg1 } | complete
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com
make help commands search term don't generate $nothing (#7896)
Relative:
https://github.com/nushell/nushell/pull/7889#issuecomment-1407503567
Make search_terms
return empty string rather than nothing, so some
other command can handle it better
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
make parse -r
columns return 0-indexed uncapitalised
Fixes #7872. Prior, =
and other assignment operators were allowed in MathExpressions
; this was probably in error.
Using "=" in RowConditions and MathExpressions now gives an error.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
This also seems to be happening for all other internal variables, eg $env
.
If anyone's trying to fix this, maybe take a look at Operator::Assignment
: the single "=" sign means eval.rs
evaluates this not as a comparison but as assignment and tries to access a var_id that does not exist.
@fdncred - in this case I think it can't easily be transferred because it's so intrinsically linked to the parse
function. However, you're definitely right about how a lot more commands should stream (which currently don't!)
move redundant code into helper function
This seems to be happening for all instances of $in in where
.
Fixes #7864.
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Check all user groups. (#7775)
Previously the group check was only for the current users gid, now we check against all the users groups.
Currently when using the cd
command to enter a directory there was
only a check against the current user id, and exact current group id,
meaning if a directory had a group permission and that group wasn't the
users group it was effectively ignored.
The fix simply implements a check through all the users current groups.
Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com
add magenta to ansi command as synonym for purple (#7785)
Added magenta
as a synonym for Purple in the ansi command. Previously,
ansi errored out on ansi magenta
as the AnsiCode
vec didn't have
magenta as a name as seen in #7747.
Users can now use the ANSI standard name magenta
.
LazyRecord (#7619)
This is an attempt to implement a new Value::LazyRecord
variant for
performance reasons.
LazyRecord
is like a regular Record
, but it's possible to access
individual columns without evaluating other columns. I've implemented
LazyRecord
for the special $nu
variable; accessing $nu
is
relatively slow because of all the information in scope
, and $nu
accounts for about 2/3 of Nu's startup time on
Linux.
I ran some benchmarks on my desktop (Linux, 12900K) and the results are very pleasing.
Nu's time to start up and run a command (cargo build --release; hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none --warmup 10
) goes from 8.8ms to 3.2ms, about 2.8x faster.
Tests are also much faster! Running cargo nextest
(with our very slow
proptest
tests disabled) goes from 7.2s to 4.4s (1.6x faster),
because most tests involve launching a new instance of Nu.
I've added a new LazyRecord
trait and added a Value
variant wrapping
those trait objects, much like CustomValue
. LazyRecord
implementations must implement these 2 functions:
// All column names
fn column_names(&self) -> Vec<&'static str>;
// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;
Value
variants must implement Serializable
and Deserializable
, which poses some problems because I want to use unserializable things like EngineState
in LazyRecord
s. To work around this, I basically lie to the type system:
#[typetag::serde(tag = "type")]
to LazyRecord
to make it serializableLazyRecord
implementations get marked with #[serde(skip)]
LazyRecord
normally would get serialized and sent to a plugin, I instead collect it into a regular Value::Record
(which can be serialized)Add test for fix of issue #7754 (#7756)
Fix already landed with #7779
let find
take linebreaks into account in Value::String
(#7789)
Fixes #7774. The functionality should be the same as feeding all
PipelineDate::Value(Value::String(_,_),_)
into lines
before putting
it into find
.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
add dedicated const in pipeline
, const builtin var
errors (#7784)
Currently let
and const
share error handling, and this might lead to
confusing error messages
This PR adds dedicated errors to const
str length
, str substring
, str index-of
, split words
and split chars
now use graphemes instead of UTF-8 bytes (#7752)
Closes https://github.com/nushell/nushell/issues/7742
Do not list deprecated subcommands in help <cmd>
(#7798)
BEFORE:
Subcommands:
str camel-case - Convert a string to camelCase
str capitalize - Capitalize first letter of text
str collect - 'str collect' is deprecated. Please use 'str join' instead.
str contains - Checks if string input contains a substring
str distance - Compare two strings and return the edit distance/Levenshtein distance
str downcase - Make text lowercase
str ends-with - Check if an input ends with a string
str find-replace - Deprecated command
str index-of - Returns start index of first occurrence of string in input, or -1 if no match
str join - Concatenate multiple strings into a single string, with an optional separator between each
str kebab-case - Convert a string to kebab-case
str length - Output the length of any strings in the pipeline
str lpad - Left-pad a string to a specific length
str pascal-case - Convert a string to PascalCase
str replace - Find and replace text
str reverse - Reverse every string in the pipeline
str rpad - Right-pad a string to a specific length
str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
str snake-case - Convert a string to snake_case
str starts-with - Check if an input starts with a string
str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
str title-case - Convert a string to Title Case
str to-datetime - Deprecated command
str to-decimal - Deprecated command
str to-int - Deprecated command
str trim - Trim whitespace or specific character
str upcase - Make text uppercase
AFTER:
Subcommands:
str camel-case - Convert a string to camelCase
str capitalize - Capitalize first letter of text
str contains - Checks if string input contains a substring
str distance - Compare two strings and return the edit distance/Levenshtein distance
str downcase - Make text lowercase
str ends-with - Check if an input ends with a string
str index-of - Returns start index of first occurrence of string in input, or -1 if no match
str join - Concatenate multiple strings into a single string, with an optional separator between each
str kebab-case - Convert a string to kebab-case
str length - Output the length of any strings in the pipeline
str lpad - Left-pad a string to a specific length
str pascal-case - Convert a string to PascalCase
str replace - Find and replace text
str reverse - Reverse every string in the pipeline
str rpad - Right-pad a string to a specific length
str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
str snake-case - Convert a string to snake_case
str starts-with - Check if an input starts with a string
str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
str title-case - Convert a string to Title Case
str trim - Trim whitespace or specific character
str upcase - Make text uppercase
The deprecated subcommands still exist, but are no longer listed in
help
for the containing command.
See above.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
fix signature display in help commands (#7802)
This PR fixes the signature display when running help commands
. Before
this PR, there were leading spaces in the signatures column. Now,
they're left aligned for a cleaner look.
Before:
After:
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
fetch
-> http get
and post
-> http post
(#7796)
This PR changes fetch
to http get
and post
to http post
. fetch
and post
are now deprecated. I surveyed people on
Discord
and users strongly approved of this change.
This PR is related to #2741 and my first pull request in rust :)
Implemented a new http mod to better http support and alias fetch
and
post
commands to http get
and http post
respectively.
Users will be able to use HTTP method via http command, for example
> http get "https://www.example.com"
<!doctype html>
<html>
...
Cleanup of src/main.rs
(#7801)
While reading nushell's code, I've started to clean up src/main.rs
a
bit.
The description of the changes can be found in the commit messages.
Move all functions of main.rs into modules (#7803)
The affected modules are:
command.rs
config_files.rs
terminal.rs
Clean up nu-cli/src/eval_file.rs
(#7804)
match
with unwrap_or_else
or if let
mut
pub(crate)
nu-table: Wrap last column in table -e
(#7778)
Hi @rgwood thank you for report.
So this PR must fix it but I'd make a few runs.
close #7763
Signed-off-by: Maxim Zhiburt zhiburt@gmail.com
Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#7806)
Bump git2 from 0.16.0 to 0.16.1 (#7807)
Bump bumpalo from 3.11.0 to 3.12.0 (#7805)
Extract manual PWD
extraction with method current_work_dir
(#7812)
Reduce number of match
calls (#7813)
[nu-test-support] Gate system locale tests (#7824)
src/locale_override.rs
is gated with #![cfg(debug_assertions)]
but
tests/get_system_locale.rs
is not; this makes cargo test --release
fails:
error[E0432]: unresolved import `nu_test_support::locale_override`
--> crates/nu-test-support/tests/get_system_locale.rs:1:22
|
1 | use nu_test_support::locale_override::with_locale_override;
| ^^^^^^^^^^^^^^^ could not find `locale_override` in `nu_test_support`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `nu-test-support` due to previous error
warning: build failed, waiting for other jobs to finish...
With the change it now passes:
❯ cargo test --release
Compiling nu-test-support v0.74.1 (/home/michel/src/github/nushell/nushell/crates/nu-test-support)
Finished release [optimized] target(s) in 7.57s
Running unittests src/lib.rs (/home/michel/src/github/nushell/nushell/target/release/deps/nu_test_support-750505b13c102d2c)
running 3 tests
test tests::constructs_a_pipeline ... ok
test playground::tests::current_working_directory_back_to_root_from_anywhere ... ok
test playground::tests::current_working_directory_in_sandbox_directory_created ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/get_system_locale.rs (/home/michel/src/github/nushell/nushell/target/release/deps/get_system_locale-e0ecabe312044fa8)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org
N/A
Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org
Date is: Tue Jan 24 04:50:05 PM +08 2023
Attempts to act as a partial solution for #7790. It works by moving the handling of exit
from within the run
itself to the repl
. (This only happens if the exit
does not happen through a nushell sub-shell.)
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Bump git2 from 0.16.0 to 0.16.1 (#7807)
Bump bumpalo from 3.11.0 to 3.12.0 (#7805)
Extract manual PWD
extraction with method current_work_dir
(#7812)
Reduce number of match
calls (#7813)
[nu-test-support] Gate system locale tests (#7824)
src/locale_override.rs
is gated with #![cfg(debug_assertions)]
but
tests/get_system_locale.rs
is not; this makes cargo test --release
fails:
error[E0432]: unresolved import `nu_test_support::locale_override`
--> crates/nu-test-support/tests/get_system_locale.rs:1:22
|
1 | use nu_test_support::locale_override::with_locale_override;
| ^^^^^^^^^^^^^^^ could not find `locale_override` in `nu_test_support`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `nu-test-support` due to previous error
warning: build failed, waiting for other jobs to finish...
With the change it now passes:
❯ cargo test --release
Compiling nu-test-support v0.74.1 (/home/michel/src/github/nushell/nushell/crates/nu-test-support)
Finished release [optimized] target(s) in 7.57s
Running unittests src/lib.rs (/home/michel/src/github/nushell/nushell/target/release/deps/nu_test_support-750505b13c102d2c)
running 3 tests
test tests::constructs_a_pipeline ... ok
test playground::tests::current_working_directory_back_to_root_from_anywhere ... ok
test playground::tests::current_working_directory_in_sandbox_directory_created ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/get_system_locale.rs (/home/michel/src/github/nushell/nushell/target/release/deps/get_system_locale-e0ecabe312044fa8)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org
N/A
Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org
Fix typos (#7811)
Some minor text fixes
Fix multi-line redirection inside a block (#7808)
Fixes: #7786
The issue is because the lite block is wrong while converting from lex tokens
Take the following as example:
❯ def foobar [] {
'hello' out> /tmp/output.1
'world' out> /tmp/output.2
}
LiteBlock { block: [
LitePipeline { commands: [
Command(None, LiteCommand { comments: [], parts: [Span { start: 40900, end:40907 }] }),
Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40913, end: 40926 }] })]
},
LitePipeline { commands: [
Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40929, end: 40936 }] }), // this is wrong, should be command.
Redirection(Span { start: 40937, end: 40941 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40942, end: 40955 }] })]
}] }
LiteBlock { block: [
LitePipeline { commands: [
Command(None, LiteCommand { comments: [], parts: [Span { start: 40824, end: 40831 }] }),
Redirection(Span { start: 40832, end: 40836 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40837, end: 40850 }] })]
},
LitePipeline { commands: [
Command(None, LiteCommand { comments: [], parts: [Span { start: 40854, end: 40861 }] }),
Redirection(Span { start: 40862, end: 40866 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40867, end: 40880 }] })]
}
] }
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
benchmark
now pipes input into the closure (#7776)
Closes #7762. See issue for motivation.
Something like this is now possible without having to split this into 2 commands:
fetch "https://www.gutenberg.org/files/11/11-0.txt" | benchmark { str downcase | split words | uniq -c | sort-by count --reverse | first 10 }
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Co-authored-by: Stefan Holderbach sholderbach@users.noreply.github.com
Feat/7725 url join (#7823)
Added command: url join
.
Closes: #7725
Converts a record to url
Search terms: scheme, username, password, hostname, port, path, query, fragment
Usage:
> url join
Flags:
-h, --help - Display the help message for this command
Signatures:
<record> | url join -> <string>
Examples:
Outputs a url representing the contents of this record
> {
"scheme": "http",
"username": "",
"password": "",
"host": "www.pixiv.net",
"port": "",
"path": "/member_illust.php",
"query": "mode=medium&illust_id=99260204",
"fragment": "",
"params":
{
"mode": "medium",
"illust_id": "99260204"
}
} | url join
Outputs a url representing the contents of this record
> {
"scheme": "http",
"username": "user",
"password": "pwd",
"host": "www.pixiv.net",
"port": "1234",
"query": "test=a",
"fragment": ""
} | url join
Outputs a url representing the contents of this record
> {
"scheme": "http",
"host": "www.pixiv.net",
"port": "1234",
"path": "user",
"fragment": "frag"
} | url join
scheme
and
host
.Allow main command to define top-level module command (#7764)
Fix command name lookup for known externals (#7830)
Fixes https://github.com/nushell/nushell/issues/7822
Bump regex from 1.6.0 to 1.7.1 (#7833)
Bump scraper from 0.13.0 to 0.14.0 (#7835)
Bump shadow-rs from 0.16.3 to 0.20.0 (#7837)
Bump miette from 5.3.0 to 5.5.0 (#7838)
Bump sysinfo from 0.26.4 to 0.27.7 (#7839)
Bump actions-rust-lang/setup-rust-toolchain from 1.3.4 to 1.3.5 (#7840)
Bumps actions-rust-lang/setup-rust-toolchain from 1.3.4 to 1.3.5.
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits
that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after
your CI passes on it@dependabot cancel merge
will cancel a previously requested merge
and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bump rayon from 1.5.3 to 1.6.1 (#7836)
Bumps rayon from 1.5.3 to 1.6.1.
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits
that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after
your CI passes on it@dependabot cancel merge
will cancel a previously requested merge
and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
print nushell startup time (#7831)
This PR shows the startup time and decreases the banner. This startup
time output can be disabled with the show_banner: false
setting in the
config. This is the startup in debug mode.
On my mac in release mode
Startup Time: 368ms 429µs 83ns
On my mac without a config as nu --config foo --env-config foo
Startup Time: 11ms 663µs 791ns
I could really go either way on this. If people don't like this change, we don't have to merge it.
Startup Time
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
sync history on exit
Fixes #7780 (?)
The functionality is borrowed from bash, but I don't have strong feelings about it. My main concern is that the substitution for the escape happens at the wrong time, which could be problematic for future maintainers.
As seen in the example,
echo "longarg" \
"longarg2"
is parsed as
echo "longarg" "longarg2"
Same can be done for flags, for instance
ls --all \
--du
Should work properly.
A backslash followed by a newline now escapes the newline.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
Ok, thanks! I'll close this for the moment until a decision is made.
Fixes #7780 (?)
The functionality is borrowed from bash, but I don't have strong feelings about it. My main concern is that the substitution for the escape happens at the wrong time, which could be problematic for future maintainers.
A backslash followed by a newline now escapes the newline.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
LazyRecord (#7619)
This is an attempt to implement a new Value::LazyRecord
variant for
performance reasons.
LazyRecord
is like a regular Record
, but it's possible to access
individual columns without evaluating other columns. I've implemented
LazyRecord
for the special $nu
variable; accessing $nu
is
relatively slow because of all the information in scope
, and $nu
accounts for about 2/3 of Nu's startup time on
Linux.
I ran some benchmarks on my desktop (Linux, 12900K) and the results are very pleasing.
Nu's time to start up and run a command (cargo build --release; hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none --warmup 10
) goes from 8.8ms to 3.2ms, about 2.8x faster.
Tests are also much faster! Running cargo nextest
(with our very slow
proptest
tests disabled) goes from 7.2s to 4.4s (1.6x faster),
because most tests involve launching a new instance of Nu.
I've added a new LazyRecord
trait and added a Value
variant wrapping
those trait objects, much like CustomValue
. LazyRecord
implementations must implement these 2 functions:
// All column names
fn column_names(&self) -> Vec<&'static str>;
// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;
Value
variants must implement Serializable
and Deserializable
, which poses some problems because I want to use unserializable things like EngineState
in LazyRecord
s. To work around this, I basically lie to the type system:
#[typetag::serde(tag = "type")]
to LazyRecord
to make it serializableLazyRecord
implementations get marked with #[serde(skip)]
LazyRecord
normally would get serialized and sent to a plugin, I instead collect it into a regular Value::Record
(which can be serialized)Add test for fix of issue #7754 (#7756)
Fix already landed with #7779
let find
take linebreaks into account in Value::String
(#7789)
Fixes #7774. The functionality should be the same as feeding all
PipelineDate::Value(Value::String(_,_),_)
into lines
before putting
it into find
.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
add dedicated const in pipeline
, const builtin var
errors (#7784)
Currently let
and const
share error handling, and this might lead to
confusing error messages
This PR adds dedicated errors to const
str length
, str substring
, str index-of
, split words
and split chars
now use graphemes instead of UTF-8 bytes (#7752)
Closes https://github.com/nushell/nushell/issues/7742
Do not list deprecated subcommands in help <cmd>
(#7798)
BEFORE:
Subcommands:
str camel-case - Convert a string to camelCase
str capitalize - Capitalize first letter of text
str collect - 'str collect' is deprecated. Please use 'str join' instead.
str contains - Checks if string input contains a substring
str distance - Compare two strings and return the edit distance/Levenshtein distance
str downcase - Make text lowercase
str ends-with - Check if an input ends with a string
str find-replace - Deprecated command
str index-of - Returns start index of first occurrence of string in input, or -1 if no match
str join - Concatenate multiple strings into a single string, with an optional separator between each
str kebab-case - Convert a string to kebab-case
str length - Output the length of any strings in the pipeline
str lpad - Left-pad a string to a specific length
str pascal-case - Convert a string to PascalCase
str replace - Find and replace text
str reverse - Reverse every string in the pipeline
str rpad - Right-pad a string to a specific length
str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
str snake-case - Convert a string to snake_case
str starts-with - Check if an input starts with a string
str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
str title-case - Convert a string to Title Case
str to-datetime - Deprecated command
str to-decimal - Deprecated command
str to-int - Deprecated command
str trim - Trim whitespace or specific character
str upcase - Make text uppercase
AFTER:
Subcommands:
str camel-case - Convert a string to camelCase
str capitalize - Capitalize first letter of text
str contains - Checks if string input contains a substring
str distance - Compare two strings and return the edit distance/Levenshtein distance
str downcase - Make text lowercase
str ends-with - Check if an input ends with a string
str index-of - Returns start index of first occurrence of string in input, or -1 if no match
str join - Concatenate multiple strings into a single string, with an optional separator between each
str kebab-case - Convert a string to kebab-case
str length - Output the length of any strings in the pipeline
str lpad - Left-pad a string to a specific length
str pascal-case - Convert a string to PascalCase
str replace - Find and replace text
str reverse - Reverse every string in the pipeline
str rpad - Right-pad a string to a specific length
str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
str snake-case - Convert a string to snake_case
str starts-with - Check if an input starts with a string
str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
str title-case - Convert a string to Title Case
str trim - Trim whitespace or specific character
str upcase - Make text uppercase
The deprecated subcommands still exist, but are no longer listed in
help
for the containing command.
See above.
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
fix signature display in help commands (#7802)
This PR fixes the signature display when running help commands
. Before
this PR, there were leading spaces in the signatures column. Now,
they're left aligned for a cleaner look.
Before:
After:
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code
stylecargo test --workspace
to check that all tests passIf your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.
fetch
-> http get
and post
-> http post
(#7796)
This PR changes fetch
to http get
and post
to http post
. fetch
and post
are now deprecated. I surveyed people on
Discord
and users strongly approved of this change.
This PR is related to #2741 and my first pull request in rust :)
Implemented a new http mod to better http support and alias fetch
and
post
commands to http get
and http post
respectively.
Users will be able to use HTTP method via http command, for example
> http get "https://www.example.com"
<!doctype html>
<html>
...
Cleanup of src/main.rs
(#7801)
While reading nushell's code, I've started to clean up src/main.rs
a
bit.
The description of the changes can be found in the commit messages.
Move all functions of main.rs into modules (#7803)
The affected modules are:
command.rs
config_files.rs
terminal.rs
Clean up nu-cli/src/eval_file.rs
(#7804)
match
with unwrap_or_else
or if let
mut
pub(crate)
nu-table: Wrap last column in table -e
(#7778)
Hi @rgwood thank you for report.
So this PR must fix it but I'd make a few runs.
close #7763
Signed-off-by: Maxim Zhiburt zhiburt@gmail.com
Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#7806)
files can multiline commands
add test and fix functionality