From 35bb9f2d1e79631ef67284b09406039df39bb5c3 Mon Sep 17 00:00:00 2001 From: Sam Hedin Date: Thu, 18 Jun 2020 07:36:53 +0200 Subject: [PATCH] Init autoenv command --- crates/nu-cli/src/commands/autoenv.rs | 30 +++++++++++++++++++++++++++ crates/nu-cli/src/env/TODO.org | 6 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 crates/nu-cli/src/commands/autoenv.rs diff --git a/crates/nu-cli/src/commands/autoenv.rs b/crates/nu-cli/src/commands/autoenv.rs new file mode 100644 index 0000000000..1cbcb8db61 --- /dev/null +++ b/crates/nu-cli/src/commands/autoenv.rs @@ -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 { + allow(args, registry).await + } + fn examples(&self) -> Vec { + vec![Example { + description: "Allow .nu-env file in current directory", + example: "autoenv trust", + result: "Current " + }] + } +} \ No newline at end of file diff --git a/crates/nu-cli/src/env/TODO.org b/crates/nu-cli/src/env/TODO.org index a8bffe6076..9f72ca3f2d 100644 --- a/crates/nu-cli/src/env/TODO.org +++ b/crates/nu-cli/src/env/TODO.org @@ -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. ** Nice errors ** Potential issues - - Functionality to re-add overwritten variables is currently untested. - - 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 \ No newline at end of file + There was previously functionality to track overwritten environment variables, which was used to restore any values that are overwritten. + 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.) \ No newline at end of file