Update and add ls examples (#13222)

# Description

Based on #13219, added several examples to `ls` doc to demonstrate
recursive directory listings. List of changes in this PR:

* Add example for `ls **/*` to demonstrate recursive listing using glob
pattern
* Add example for `ls ...(glob )`... to demonstrate recursive listing
using glob command
* Remove `-s` from an example where it had no use (since it was based on
the current directory and was not recursive)
* Update the description of `ls -a ~ `... to clarify that it lists the
full path of directories
* Update the description of `ls -as ~ `... (the difference being the
`-s`) to clarify that it lists only the filenames, not paths.


# User-Facing Changes

Help only

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

N/A
This commit is contained in:
NotTheDr01ds 2024-06-26 18:49:52 -04:00 committed by GitHub
parent 020f4436d9
commit 58e8ea6084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -175,20 +175,32 @@ impl Command for Ls {
}, },
Example { Example {
description: "List files and directories whose name do not contain 'bar'", description: "List files and directories whose name do not contain 'bar'",
example: "ls -s | where name !~ bar", example: "ls | where name !~ bar",
result: None, result: None,
}, },
Example { Example {
description: "List all dirs in your home directory", description: "List the full path of all dirs in your home directory",
example: "ls -a ~ | where type == dir", example: "ls -a ~ | where type == dir",
result: None, result: None,
}, },
Example { Example {
description: description:
"List all dirs in your home directory which have not been modified in 7 days", "List only the names (not paths) of all dirs in your home directory which have not been modified in 7 days",
example: "ls -as ~ | where type == dir and modified < ((date now) - 7day)", example: "ls -as ~ | where type == dir and modified < ((date now) - 7day)",
result: None, result: None,
}, },
Example {
description:
"Recursively list all files and subdirectories under the current directory using a glob pattern",
example: "ls -a **/*",
result: None,
},
Example {
description:
"Recursively list *.rs and *.toml files using the glob command",
example: "ls ...(glob **/*.{rs,toml})",
result: None,
},
Example { Example {
description: "List given paths and show directories themselves", description: "List given paths and show directories themselves",
example: "['/path/to/directory' '/path/to/file'] | each {|| ls -D $in } | flatten", example: "['/path/to/directory' '/path/to/file'] | each {|| ls -D $in } | flatten",