Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lang and snippets updates #1699

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lang-guide/chapters/strings_and_text.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ Sometimes you need to nest quotes. I think this could use some work because some
The key to always remember is that double quotes recognize and interpret escapes so if you have any `\` characters in your string, they will be interpreted as escapes. The following is an example of a question we get frequently on Discord.

```nu
Why doesn't this work?
> cd "C:\Program Files\somedir"
# Why doesn't this work?
cd "C:\Program Files\somedir"
```

It doesn't work because it sees `\P` and `\s` as escapes that are not recognized.
Expand Down
28 changes: 14 additions & 14 deletions lang-guide/chapters/types/basic_types/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
Table literals can be created using a syntax similar to that of a list literal. Because tables also contain columns and not just values, we also specify the column names:

```nu
> [[column1, column2]; [Value1, Value2] [Value3, Value4]]
╭───┬─────────┬─────────╮
│ # │ column1 │ column2 │
├───┼─────────┼─────────┤
│ 0 │ Value1 │ Value2 │
│ 1 │ Value3 │ Value4 │
╰───┴─────────┴─────────╯
[[column1, column2]; [Value1, Value2] [Value3, Value4]]
# => ╭───┬─────────┬─────────╮
# => │ # │ column1 │ column2 │
# => ├───┼─────────┼─────────┤
# => │ 0 │ Value1 │ Value2 │
# => │ 1 │ Value3 │ Value4 │
# => ╰───┴─────────┴─────────╯
```

In this syntax, the headers are separated from the data cells using a semicolon(`;`). The semicolon separator is mandatory in a table-literal. It must follow the headers.
Expand All @@ -33,13 +33,13 @@ In this syntax, the headers are separated from the data cells using a semicolon(
You can also create a table as a list of records, JSON-style:

```nu
> [{name: "Sam", rank: 10}, {name: "Bob", rank: 7}]
╭───┬──────┬──────╮
│ # │ name │ rank │
├───┼──────┼──────┤
│ 0 │ Sam │ 10 │
│ 1 │ Bob │ 7 │
╰───┴──────┴──────╯
[{name: "Sam", rank: 10}, {name: "Bob", rank: 7}]
# => ╭───┬──────┬──────╮
# => │ # │ name │ rank │
# => ├───┼──────┼──────┤
# => │ 0 │ Sam │ 10 │
# => │ 1 │ Bob │ 7 │
# => ╰───┴──────┴──────╯
```

This list-of-records pattern plays on the Nushell data model, which sees a list of records as equivalent to a table. This is useful in cases where the length of a table may not be known ahead of time. In such a case, a stream of records likewise represents a table.
Expand Down
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
3 changes: 1 addition & 2 deletions snippets/installation/windows_run_nu.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
> nu
C:\Users\user>
nu
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
Loading
Loading