Documentation for autoenv (#2163)

* Documentation

* Somewhat nicer?

* cat
This commit is contained in:
Sam Hedin 2020-07-13 08:23:19 +02:00 committed by GitHub
parent 5a34744d8c
commit 78f13407e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 5 deletions

View file

@ -55,8 +55,13 @@ impl WholeStreamCommand for Autoenv {
}
fn usage(&self) -> &str {
// "Mark a .nu-env file in a directory as trusted. Needs to be re-run after each change to the file or its filepath."
"Manage directory specific environments"
r#"Manage directory specific environment variables and scripts. Create a file called .nu-env in any directory and run 'autoenv trust' to let nushell read it when entering the directory.
The file can contain several optional sections:
env: environment variables to set when visiting the directory. The variables are unset after leaving the directory and any overwritten values are restored.
scriptvars: environment variables that should be set to the return value of a script. After they have been set, they behave in the same way as variables set in the env section.
scripts: scripts to run when entering the directory or leaving it. Note that exitscripts are not run in the directory they are declared in."#
}
fn signature(&self) -> Signature {
Signature::build("autoenv")
}
@ -74,8 +79,17 @@ impl WholeStreamCommand for Autoenv {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Allow .nu-env file in current directory",
example: "autoenv trust",
description: "Example .nu-env file",
example: r#"cat .nu-env
[env]
mykey = "myvalue"
[scriptvars]
myscript = "echo myval"
[scripts]
entryscripts = ["touch hello.txt", "touch hello2.txt"]
exitscripts = ["touch bye.txt"]"#,
result: None,
}]
}

View file

@ -69,6 +69,17 @@ impl WholeStreamCommand for AutoenvTrust {
false
}
fn examples(&self) -> Vec<Example> {
Vec::new()
vec![
Example {
description: "Allow .nu-env file in current directory",
example: "autoenv trust",
result: None,
},
Example {
description: "Allow .nu-env file in directory foo",
example: "autoenv trust foo",
result: None,
},
]
}
}

View file

@ -93,6 +93,17 @@ impl WholeStreamCommand for AutoenvUnTrust {
false
}
fn examples(&self) -> Vec<Example> {
Vec::new()
vec![
Example {
description: "Disallow .nu-env file in current directory",
example: "autoenv untrust",
result: None,
},
Example {
description: "Disallow .nu-env file in directory foo",
example: "autoenv untrust foo",
result: None,
},
]
}
}