Init autoenv command
This commit is contained in:
parent
a173817889
commit
35bb9f2d1e
30
crates/nu-cli/src/commands/autoenv.rs
Normal file
30
crates/nu-cli/src/commands/autoenv.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
use crate::commands::WholeStreamCommand;
|
||||||
|
use crate::prelude::*;
|
||||||
|
use nu_errors::ShellError;
|
||||||
|
use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value};
|
||||||
|
|
||||||
|
pub struct Autoenv;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl WholeStreamCommand for Autoenv {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"autoenv"
|
||||||
|
}
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Mark a .nu-env file in a directory as trusted. Needs to be re-made after each change to the file."
|
||||||
|
}
|
||||||
|
async fn run(
|
||||||
|
&self,
|
||||||
|
args: CommandArgs,
|
||||||
|
registry: &CommandRegistry,
|
||||||
|
) -> Result<OutputStream, ShellError> {
|
||||||
|
allow(args, registry).await
|
||||||
|
}
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Allow .nu-env file in current directory",
|
||||||
|
example: "autoenv trust",
|
||||||
|
result: "Current "
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
6
crates/nu-cli/src/env/TODO.org
vendored
6
crates/nu-cli/src/env/TODO.org
vendored
|
@ -27,5 +27,7 @@ returning =None=, which completely skips running the code for dealing with direc
|
||||||
- Add command to clear allowed .nu-envs in a directory.
|
- Add command to clear allowed .nu-envs in a directory.
|
||||||
** Nice errors
|
** Nice errors
|
||||||
** Potential issues
|
** Potential issues
|
||||||
- Functionality to re-add overwritten variables is currently untested.
|
There was previously functionality to track overwritten environment variables, which was used to restore any values that are overwritten.
|
||||||
- Needs to be tested with what happens if you set a variable in the current session from some other source than .nu-env or config.toml
|
However, it seems that with the current version the already existing nushell functionality takes care of this, in every case I can come up with.
|
||||||
|
Because of that, I just removed the code. It's still there, in the venerable git log if anything ever changes `acd3215b` `Remove overwritten values tracking, as it is not needed`.
|
||||||
|
(I am making a note of this as I half expect someone to come up with a scenario which requires this to be re-added.)
|
Loading…
Reference in New Issue
Block a user