mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 17:03:45 +01:00
Add args in .nurc file to environment
This commit is contained in:
parent
b6f9d0ca58
commit
83795a3e70
12
crates/nu-cli/src/env/environment.rs
vendored
12
crates/nu-cli/src/env/environment.rs
vendored
@ -3,6 +3,8 @@ use indexmap::{indexmap, IndexSet};
|
|||||||
use nu_protocol::{UntaggedValue, Value};
|
use nu_protocol::{UntaggedValue, Value};
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
pub trait Env: Debug + Send {
|
pub trait Env: Debug + Send {
|
||||||
fn env(&self) -> Option<Value>;
|
fn env(&self) -> Option<Value>;
|
||||||
@ -44,6 +46,16 @@ impl Environment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_nurc(&mut self) {
|
||||||
|
let key = "envtest";
|
||||||
|
let value = "I am here!";
|
||||||
|
|
||||||
|
let mut file = File::create("env.txt").unwrap();
|
||||||
|
write!(&mut file, "{:?}", "somedata").unwrap();
|
||||||
|
|
||||||
|
self.add_env(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_config<T: Conf>(configuration: &T) -> Environment {
|
pub fn from_config<T: Conf>(configuration: &T) -> Environment {
|
||||||
let env = configuration.env();
|
let env = configuration.env();
|
||||||
let path = configuration.path();
|
let path = configuration.path();
|
||||||
|
2
crates/nu-cli/src/env/environment_syncer.rs
vendored
2
crates/nu-cli/src/env/environment_syncer.rs
vendored
@ -70,6 +70,8 @@ impl EnvironmentSyncer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment.add_nurc();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sync_path_vars(&mut self, ctx: &mut Context) {
|
pub fn sync_path_vars(&mut self, ctx: &mut Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user