nushell/crates/nu-command/tests/commands
Doru 3d65fd7cc4
Expose filtering by file type in glob (#7834)
# Description

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](https://docs.rs/wax/latest/wax/struct.WalkEntry.html#method.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

# User-Facing Changes
Three new flags when using `glob` and a slightly more cluttered help
page. No breaking changes, I hope.

# Tests + Formatting

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
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-01-28 07:50:12 -06:00
..
assignment ++= appendAssign operator (#7346) (#7354) 2022-12-09 11:20:58 -05:00
date Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
hash_ Deprecate hash base64, extend decode and add encode commands (#5863) 2022-06-26 00:35:23 +03:00
math Remove math eval command (#7284) 2023-01-04 23:50:18 +01:00
move_
network Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
path
platform Return error when kill didn't terminate successfully (#6354) 2022-08-18 11:58:51 -05:00
query
random Another batch of command tests (#4496) 2022-02-16 07:38:02 -05:00
skip last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623) 2022-12-31 13:35:12 +02:00
str_ Remove math eval command (#7284) 2023-01-04 23:50:18 +01:00
take last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623) 2022-12-31 13:35:12 +02:00
url Feat/7725 url join (#7823) 2023-01-22 19:49:40 +01:00
alias.rs Expand Nushell's help system (#7611) 2022-12-30 17:44:37 +02:00
all.rs
any.rs
append.rs revert changes on prepend and append (#7660) 2023-01-02 17:09:55 -08:00
break_.rs
cal.rs return Error if get meet nothing and without "i" (#7002) 2022-12-31 13:27:09 +02:00
cd.rs fix some typos (#7773) 2023-01-16 12:43:46 +01:00
compact.rs
continue_.rs
cp.rs
def.rs def: make various punctuation misuses into errors (#7624) 2022-12-31 13:18:53 +02:00
default.rs Make get hole errors and cell path hole errors identical (improvement on #7002) (#7647) 2023-01-02 14:45:43 -08:00
do_.rs Fix pipeline stall in do during capture and remove excessive redirections (#7204) 2023-01-25 00:24:38 -05:00
drop.rs last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623) 2022-12-31 13:35:12 +02:00
each.rs
echo.rs
empty.rs
enter.rs
error_make.rs
every.rs
exec.rs Add "fall-through" signatures (#7527) 2022-12-22 00:33:26 +02:00
export_def.rs
find.rs let find take linebreaks into account in Value::String (#7789) 2023-01-20 00:07:34 +01:00
first.rs Make stream info visible to users in describe (#7589) 2023-01-03 21:08:05 -08:00
flatten.rs
for_.rs Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
format.rs
g.rs
get.rs Make get hole errors and cell path hole errors identical (improvement on #7002) (#7647) 2023-01-02 14:45:43 -08:00
glob.rs Expose filtering by file type in glob (#7834) 2023-01-28 07:50:12 -06:00
group_by.rs
headers.rs
help.rs Allow main command to define top-level module command (#7764) 2023-01-22 21:34:15 +02:00
histogram.rs
insert.rs
into_filesize.rs
into_int.rs
last.rs Make stream info visible to users in describe (#7589) 2023-01-03 21:08:05 -08:00
length.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
let_.rs
lines.rs
loop_.rs Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
ls.rs Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
merge.rs
mkdir.rs
mod.rs Make to text stream ListStreams (#7577) 2022-12-22 16:38:07 -08:00
mut_.rs
n.rs
nu_check.rs
open.rs Make get hole errors and cell path hole errors identical (improvement on #7002) (#7647) 2023-01-02 14:45:43 -08:00
p.rs
parse.rs Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
prepend.rs revert changes on prepend and append (#7660) 2023-01-02 17:09:55 -08:00
print.rs
range.rs
redirection.rs Fix multi-line redirection inside a block (#7808) 2023-01-23 06:32:56 +13:00
reduce.rs Remove math eval command (#7284) 2023-01-04 23:50:18 +01:00
reject.rs
rename.rs Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
return_.rs
reverse.rs last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623) 2022-12-31 13:35:12 +02:00
rm.rs
roll.rs Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
rotate.rs str collect => str join (#6531) 2022-09-11 11:48:27 +03:00
run_external.rs Trim quotes when shelling out to cmd.exe (#7740) 2023-01-13 11:00:30 -08:00
save.rs Fix pipeline stall in do during capture and remove excessive redirections (#7204) 2023-01-25 00:24:38 -05:00
select.rs Make get hole errors and cell path hole errors identical (improvement on #7002) (#7647) 2023-01-02 14:45:43 -08:00
semicolon.rs
seq_char.rs
seq.rs Make stream info visible to users in describe (#7589) 2023-01-03 21:08:05 -08:00
shells.rs
sort_by.rs last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623) 2022-12-31 13:35:12 +02:00
sort.rs
source_env.rs Initial support for parse-time constants (#7436) 2022-12-22 00:21:03 +02:00
split_by.rs
split_column.rs
split_row.rs
table.rs nu-commands/table (table -e) Recognize limited space better (#7861) 2023-01-26 14:06:17 -06:00
to_text.rs Make to text stream ListStreams (#7577) 2022-12-22 16:38:07 -08:00
touch.rs
transpose.rs Prevents duplicate fields in transpose -r (#5840) 2022-06-22 19:19:06 -05:00
try_.rs fix some typos (#7773) 2023-01-16 12:43:46 +01:00
uniq_by.rs
uniq.rs uniq -i does not convert to lowercase (#7192) (#7209) 2022-11-23 15:46:20 -08:00
update.rs
upsert.rs
use_.rs Allow main command to define top-level module command (#7764) 2023-01-22 21:34:15 +02:00
where_.rs nu-commands/table (table -e) Recognize limited space better (#7861) 2023-01-26 14:06:17 -06:00
which.rs
while_.rs Fix typos and use more idiomatic assertions (#7755) 2023-01-15 15:03:32 +13:00
with_env.rs Change other instances of $nothing to null (#7569) 2022-12-22 12:30:10 -08:00
wrap.rs
zip.rs Better errors when bash-like operators are used (#7241) 2022-12-08 12:02:11 +13:00