Doc and examples for multi-dot directory traversal (#13513)

# Description

With this PR, we should be able to close
https://github.com/nushell/nushell.github.io/issues/1225

Help/doc/examples updated for:

* `cd` to show multi-dot traversal
* `cd` to show implicit `cd` with bare directory path
* Fixed/clarified another example that mentioned `$OLDPATH` while I was
in there
* `mv` and `cp` examples for multi-dot traversal
* Updated `cp` examples to use more consistent (and clear) filenames

# User-Facing Changes

Help/doc only

# Tests + Formatting

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

# After Submitting

N/A
This commit is contained in:
NotTheDr01ds 2024-08-01 16:22:25 -04:00 committed by GitHub
parent 168835ecd2
commit ca8eb856e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 4 deletions

View File

@ -134,7 +134,7 @@ impl Command for Cd {
result: None,
},
Example {
description: "Change to the previous working directory ($OLDPWD)",
description: r#"Change to the previous working directory (same as "cd $env.OLDPWD")"#,
example: r#"cd -"#,
result: None,
},
@ -143,6 +143,16 @@ impl Command for Cd {
example: r#"def --env gohome [] { cd ~ }"#,
result: None,
},
Example {
description: "Move two directories up in the tree (the parent directory's parent). Additional dots can be added for additional levels.",
example: r#"cd ..."#,
result: None,
},
Example {
description: "The cd command itself is often optional. Simply entering a path to a directory will cd to it.",
example: r#"/home"#,
result: None,
},
]
}
}

View File

@ -86,17 +86,22 @@ impl Command for UCp {
},
Example {
description: "Copy only if source file is newer than target file",
example: "cp -u a b",
example: "cp -u myfile newfile",
result: None,
},
Example {
description: "Copy file preserving mode and timestamps attributes",
example: "cp --preserve [ mode timestamps ] a b",
example: "cp --preserve [ mode timestamps ] myfile newfile",
result: None,
},
Example {
description: "Copy file erasing all attributes",
example: "cp --preserve [] a b",
example: "cp --preserve [] myfile newfile",
result: None,
},
Example {
description: "Copy file to a directory three levels above its current location",
example: "cp myfile ....",
result: None,
},
]

View File

@ -40,6 +40,11 @@ impl Command for UMv {
example: "mv *.txt my/subdirectory",
result: None,
},
Example {
description: r#"Move a file into the "my" directory two levels up in the directory tree"#,
example: "mv test.txt .../my/",
result: None,
},
]
}