mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +00:00
cd
/def --env
examples (#13068)
# Description Per a Discord question (https://discord.com/channels/601130461678272522/1244293194603167845/1247794228696711198), this adds examples to the `help` for both: * `cd` * `def` to demonstrate that `def --env` is required when changing directories in a custom command. Since the existing examples for `def` were a bit more complex (and had output) but the `cd` ones were more simplified, I did use slightly different examples in each. Either or both could be tweaked if desired. # User-Facing Changes Command `help` examples # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A --------- Co-authored-by: Jakub Žádník <kubouch@gmail.com>
This commit is contained in:
parent
78fdb2f4d1
commit
36ad7f15c4
2 changed files with 10 additions and 0 deletions
|
@ -60,6 +60,11 @@ impl Command for Def {
|
|||
example: r#"def --env foo [] { $env.BAR = "BAZ" }; foo; $env.BAR"#,
|
||||
result: Some(Value::test_string("BAZ")),
|
||||
},
|
||||
Example {
|
||||
description: "cd affects the environment, so '--env' is required to change directory from within a command",
|
||||
example: r#"def --env gohome [] { cd ~ }; gohome; $env.PWD == ('~' | path expand)"#,
|
||||
result: Some(Value::test_string("true")),
|
||||
},
|
||||
Example {
|
||||
description: "Define a custom wrapper for an external command",
|
||||
example: r#"def --wrapped my-echo [...rest] { echo $rest }; my-echo spam"#,
|
||||
|
|
|
@ -135,6 +135,11 @@ impl Command for Cd {
|
|||
example: r#"cd -"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Changing directory with a custom command requires 'def --env'",
|
||||
example: r#"def --env gohome [] { cd ~ }"#,
|
||||
result: None,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue