add examples with .. and / to path join (#10620)

related to
-
https://discord.com/channels/601130461678272522/615329862395101194/1159484770468773990

# Description
because the following might not be trivial
```nushell
> "/foo/bar" | path join "/" "baz"
/baz
```
i thought adding a few examples to the `path join` command might help
😇

# User-Facing Changes
two new examples in `help path join` one with `..` and the other with
`/` 👍

# Tests + Formatting
the examples have `result`s so that they are checked.

# After Submitting

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
Antoine Stevan 2023-10-09 18:58:32 +02:00 committed by GitHub
parent ce09186e2e
commit 0b651b6372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,6 +90,17 @@ the output of 'path parse' and 'path split' subcommands."#
example: r"'C:\Users\viking' | path join spams this_spam.txt",
result: Some(Value::test_string(r"C:\Users\viking\spams\this_spam.txt")),
},
Example {
description: "Use relative paths, e.g. '..' will go up one directory",
example: r"'C:\Users\viking' | path join .. folder",
result: Some(Value::test_string(r"C:\Users\viking\..\folder")),
},
Example {
description:
"Use absolute paths, e.g. '/' will bring you to the top level directory",
example: r"'C:\Users\viking' | path join / folder",
result: Some(Value::test_string(r"C:/folder")),
},
Example {
description: "Join a list of parts into a path",
example: r"[ 'C:' '\' 'Users' 'viking' 'spam.txt' ] | path join",
@ -124,6 +135,17 @@ the output of 'path parse' and 'path split' subcommands."#
example: r"'/home/viking' | path join spams this_spam.txt",
result: Some(Value::test_string(r"/home/viking/spams/this_spam.txt")),
},
Example {
description: "Use relative paths, e.g. '..' will go up one directory",
example: r"'/home/viking' | path join .. folder",
result: Some(Value::test_string(r"/home/viking/../folder")),
},
Example {
description:
"Use absolute paths, e.g. '/' will bring you to the top level directory",
example: r"'/home/viking' | path join / folder",
result: Some(Value::test_string(r"/folder")),
},
Example {
description: "Join a list of parts into a path",
example: r"[ '/' 'home' 'viking' 'spam.txt' ] | path join",