Skip to content

Commit

Permalink
update snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4D5352 committed Dec 22, 2024
1 parent 5e730da commit c2c02d5
Show file tree
Hide file tree
Showing 36 changed files with 228 additions and 226 deletions.
2 changes: 1 addition & 1 deletion snippets/book/moving_around/cd_example.nu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
> cd new_directory
cd new_directory
2 changes: 1 addition & 1 deletion snippets/book/moving_around/cd_without_command_example.nu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
> ./new_directory
./new_directory
12 changes: 6 additions & 6 deletions snippets/book/moving_around/multiple_cd_levels.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Change to the parent directory
> cd ..
cd ..
# or
> ..
..
# Go up two levels (parent's parent)
> cd ...
cd ...
# or
> ...
...
# Go up three levels (parent of parent's parent)
> cd ....
# Etc.
cd ....
# Etc.
2 changes: 1 addition & 1 deletion snippets/book/moving_around/relative_cd_levels.nu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
> cd ../sibling
cd ../sibling
5 changes: 3 additions & 2 deletions snippets/installation/build_nu_from_source.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
> cd nushell
nushell> cargo build --workspace; cargo run
cd nushell
# ./nushell
cargo build --workspace; cargo run
2 changes: 1 addition & 1 deletion snippets/installation/build_nu_from_source_release.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nushell> cargo build --release --workspace; cargo run --release
cargo build --release --workspace; cargo run --release
7 changes: 4 additions & 3 deletions snippets/installation/build_nu_yourself.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
> git clone https://github.com/nushell/nushell.git
> cd nushell
nushell> cargo install --path . --locked
git clone https://github.com/nushell/nushell.git
cd nushell
# ./nushell
cargo install --path . --locked
2 changes: 1 addition & 1 deletion snippets/installation/cargo_install_nu.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
> cargo install nu --locked
cargo install nu --locked
2 changes: 1 addition & 1 deletion snippets/installation/git_clone_nu.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
> git clone https://github.com/nushell/nushell.git
git clone https://github.com/nushell/nushell.git
4 changes: 2 additions & 2 deletions snippets/installation/windows_run_nu.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
> nu
C:\Users\user>
nu
# => C:\Users\user>
4 changes: 2 additions & 2 deletions snippets/introduction/date_example.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
> date now
2022-03-07 14:14:51.684619600 -08:00
date now
# => 2022-03-07 14:14:51.684619600 -08:00
12 changes: 6 additions & 6 deletions snippets/introduction/date_table_example.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> date now | date to-table
╭───┬──────┬───────┬─────┬──────┬────────┬────────┬──────────╮
# │ year │ month │ day │ hour │ minute │ second │ timezone │
├───┼──────┼───────┼─────┼──────┼────────┼────────┼──────────┤
│ 0 │ 2022 │ 3 │ 7 │ 14 │ 45 │ 3 │ -08:00 │
╰───┴──────┴───────┴─────┴──────┴────────┴────────┴──────────╯
date now | date to-table
# => ╭───┬──────┬───────┬─────┬──────┬────────┬────────┬──────────╮
# => │ # │ year │ month │ day │ hour │ minute │ second │ timezone │
# => ├───┼──────┼───────┼─────┼──────┼────────┼────────┼──────────┤
# => │ 0 │ 2022 │ 3 │ 7 │ 14 │ 45 │ 3 │ -08:00 │
# => ╰───┴──────┴───────┴─────┴──────┴────────┴────────┴──────────╯
44 changes: 22 additions & 22 deletions snippets/introduction/help_commands_each_example.nu
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
> help commands | where name == each | first
╭──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────╮
name each
category filters
command_type built-in
usage Run a closure on each row of the input list, creating a new list with the results.
╭───┬──────────────────┬──────────────┬──────────┬───────────────────────────────────────────╮
params # │ name │ type │ required │ description │ │
├───┼──────────────────┼──────────────┼──────────┼───────────────────────────────────────────┤
0 closure closure(any) true The closure to run.
1 --help(-h) switch false Display the help message for this command
2 --keep-empty(-k) switch false keep empty result cells
╰───┴──────────────────┴──────────────┴──────────┴───────────────────────────────────────────╯
╭───┬───────────┬───────────╮
input_output # │ input │ output │ │
├───┼───────────┼───────────┤
0 list<any> list<any>
1 table list<any>
2 any any
╰───┴───────────┴───────────╯
search_terms for, loop, iterate, map
╰──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────╯
> commands | where name == each | first
# => ╭──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────╮
# => │ name │ each │
# => │ category │ filters │
# => │ command_type │ built-in │
# => │ usage │ Run a closure on each row of the input list, creating a new list with the results. │
# => │ │ ╭───┬──────────────────┬──────────────┬──────────┬───────────────────────────────────────────╮ │
# => │ params │ │ # │ name │ type │ required │ description │ │
# => │ │ ├───┼──────────────────┼──────────────┼──────────┼───────────────────────────────────────────┤ │
# => │ │ │ 0 │ closure │ closure(any) │ true │ The closure to run. │ │
# => │ │ │ 1 │ --help(-h) │ switch │ false │ Display the help message for this command │ │
# => │ │ │ 2 │ --keep-empty(-k) │ switch │ false │ keep empty result cells │ │
# => │ │ ╰───┴──────────────────┴──────────────┴──────────┴───────────────────────────────────────────╯ │
# => │ │ ╭───┬───────────┬───────────╮ │
# => │ input_output │ │ # │ input │ output │ │
# => │ │ ├───┼───────────┼───────────┤ │
# => │ │ │ 0 │ list<any> │ list<any> │ │
# => │ │ │ 1 │ table │ list<any> │ │
# => │ │ │ 2 │ any │ any │ │
# => │ │ ╰───┴───────────┴───────────╯ │
# => │ search_terms │ for, loop, iterate, map │
# => ╰──────────────┴────────────────────────────────────────────────────────────────────────────────────────────────╯
12 changes: 6 additions & 6 deletions snippets/introduction/help_commands_get_cell_path_example.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> help commands | where name == each | get 0.params.name
╭───┬──────────────────╮
0 closure
1 --help(-h)
2 --keep-empty(-k)
╰───┴──────────────────╯
help commands | where name == each | get 0.params.name
# => ╭───┬──────────────────╮
# => │ 0 │ closure │
# => │ 1 │ --help(-h) │
# => │ 2 │ --keep-empty(-k) │
# => ╰───┴──────────────────╯
16 changes: 8 additions & 8 deletions snippets/introduction/help_commands_get_example.nu
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
> help commands | where name == each | first | get params
╭───┬──────────────────┬──────────────┬──────────┬───────────────────────────────────────────╮
# │ name │ type │ required │ description │
├───┼──────────────────┼──────────────┼──────────┼───────────────────────────────────────────┤
0 closure closure(any) true The closure to run.
1 --help(-h) switch false Display the help message for this command
2 --keep-empty(-k) switch false keep empty result cells
╰───┴──────────────────┴──────────────┴──────────┴───────────────────────────────────────────╯
help commands | where name == each | first | get params
# => ╭───┬──────────────────┬──────────────┬──────────┬───────────────────────────────────────────╮
# => │ # │ name │ type │ required │ description │
# => ├───┼──────────────────┼──────────────┼──────────┼───────────────────────────────────────────┤
# => │ 0 │ closure │ closure(any) │ true │ The closure to run. │
# => │ 1 │ --help(-h) │ switch │ false │ Display the help message for this command │
# => │ 2 │ --keep-empty(-k) │ switch │ false │ keep empty result cells │
# => ╰───┴──────────────────┴──────────────┴──────────┴───────────────────────────────────────────╯
12 changes: 6 additions & 6 deletions snippets/introduction/help_commands_get_nested_example.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> help commands | where name == each | first | get params.name
╭───┬──────────────────╮
0 closure
1 --help(-h)
2 --keep-empty(-k)
╰───┴──────────────────╯
help commands | where name == each | first | get params.name
# => ╭───┬──────────────────╮
# => │ 0 │ closure │
# => │ 1 │ --help(-h) │
# => │ 2 │ --keep-empty(-k) │
# => ╰───┴──────────────────╯
66 changes: 33 additions & 33 deletions snippets/introduction/help_example.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
> help path
Explore and manipulate paths.

There are three ways to represent a path:

* As a path literal, e.g., '/home/viking/spam.txt'
* As a structured path: a table with 'parent', 'stem', and 'extension' (and
* 'prefix' on Windows) columns. This format is produced by the 'path parse'
subcommand.
* As an inner list of path parts, e.g., '[[ / home viking spam.txt ]]'.
Splitting into parts is done by the `path split` command.

All subcommands accept all three variants as an input. Furthermore, the 'path
join' subcommand can be used to join the structured path or path parts back into
the path literal.

Usage:
> path

Subcommands:
path basename - Get the final component of a path
path dirname - Get the parent directory of a path
path exists - Check whether a path exists
path expand - Try to expand a path to its absolute form
path join - Join a structured path or a list of path parts.
path parse - Convert a path into structured data.
path relative-to - Get a path as relative to another path.
path split - Split a path into parts by a separator.
path type - Get the type of the object a path refers to (e.g., file, dir, symlink)

Flags:
-h, --help
Display this help message
help path
# => Explore and manipulate paths.
# =>
# => There are three ways to represent a path:
# =>
# => * As a path literal, e.g., '/home/viking/spam.txt'
# => * As a structured path: a table with 'parent', 'stem', and 'extension' (and
# => * 'prefix' on Windows) columns. This format is produced by the 'path parse'
# => subcommand.
# => * As an inner list of path parts, e.g., '[[ / home viking spam.txt ]]'.
# => Splitting into parts is done by the `path split` command.
# =>
# => All subcommands accept all three variants as an input. Furthermore, the 'path
# => join' subcommand can be used to join the structured path or path parts back into
# => the path literal.
# =>
# => Usage:
# => > path
# =>
# => Subcommands:
# => path basename - Get the final component of a path
# => path dirname - Get the parent directory of a path
# => path exists - Check whether a path exists
# => path expand - Try to expand a path to its absolute form
# => path join - Join a structured path or a list of path parts.
# => path parse - Convert a path into structured data.
# => path relative-to - Get a path as relative to another path.
# => path split - Split a path into parts by a separator.
# => path type - Get the type of the object a path refers to (e.g., file, dir, symlink)
# =>
# => Flags:
# => -h, --help
# => Display this help message
22 changes: 11 additions & 11 deletions snippets/introduction/ls_example.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
> ls
╭────┬───────────────────────┬──────┬───────────┬─────────────╮
# │ name │ type │ size │ modified │
├────┼───────────────────────┼──────┼───────────┼─────────────┤
│ 0 │ 404.html │ file │ 429 B │ 3 days ago │
│ 1 │ CONTRIBUTING.md │ file │ 955 B │ 8 mins ago │
│ 2 │ Gemfile │ file │ 1.1 KiB │ 3 days ago │
│ 3 │ Gemfile.lock │ file │ 6.9 KiB │ 3 days ago │
│ 4 │ LICENSE │ file │ 1.1 KiB │ 3 days ago │
│ 5 │ README.md │ file │ 213 B │ 3 days ago │
...
ls
# => ╭────┬───────────────────────┬──────┬───────────┬─────────────╮
# => │ # │ name │ type │ size │ modified │
# => ├────┼───────────────────────┼──────┼───────────┼─────────────┤
# => │ 0 │ 404.html │ file │ 429 B │ 3 days ago │
# => │ 1 │ CONTRIBUTING.md │ file │ 955 B │ 8 mins ago │
# => │ 2 │ Gemfile │ file │ 1.1 KiB │ 3 days ago │
# => │ 3 │ Gemfile.lock │ file │ 6.9 KiB │ 3 days ago │
# => │ 4 │ LICENSE │ file │ 1.1 KiB │ 3 days ago │
# => │ 5 │ README.md │ file │ 213 B │ 3 days ago │
# => ...
Loading

0 comments on commit c2c02d5

Please sign in to comment.