mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 10:18:30 +02:00
Treating environment variables as Values (#497)
* Proof of concept treating env vars as Values * Refactor env var collection and method name * Remove unnecessary pub * Move env translations into a new file * Fix LS_COLORS to support any Value * Fix spans during env var translation * Add span to env var in cd * Improve error diagnostics * Fix non-string env vars failing string conversion * Make PROMPT_COMMAND a Block instead of String * Record host env vars to a fake file This will give spans to env vars that would otherwise be without one. Makes errors less confusing. * Add 'env' command to list env vars It will list also their values translated to strings * Sort env command by name; Add env var type * Remove obsolete test
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// use super::icons::{icon_for_file, iconify_style_ansi_to_nu};
|
||||
use super::icons::icon_for_file;
|
||||
use lscolors::{LsColors, Style};
|
||||
use nu_engine::env_to_string;
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
ast::{Call, PathMember},
|
||||
@ -61,7 +62,10 @@ prints out the list properly."#
|
||||
let color_param: bool = call.has_flag("color");
|
||||
let separator_param: Option<String> = call.get_flag(engine_state, stack, "separator")?;
|
||||
let config = stack.get_config().unwrap_or_default();
|
||||
let env_str = stack.get_env_var("LS_COLORS");
|
||||
let env_str = match stack.get_env_var("LS_COLORS") {
|
||||
Some(v) => Some(env_to_string("LS_COLORS", v, engine_state, stack, &config)?),
|
||||
None => None,
|
||||
};
|
||||
let use_grid_icons = config.use_grid_icons;
|
||||
|
||||
match input {
|
||||
|
@ -1,5 +1,6 @@
|
||||
use lscolors::{LsColors, Style};
|
||||
use nu_color_config::{get_color_config, style_primitive};
|
||||
use nu_engine::env_to_string;
|
||||
use nu_protocol::ast::{Call, PathMember};
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
@ -74,7 +75,13 @@ impl Command for Table {
|
||||
let ctrlc = ctrlc.clone();
|
||||
|
||||
let ls_colors = match stack.get_env_var("LS_COLORS") {
|
||||
Some(s) => LsColors::from_string(&s),
|
||||
Some(v) => LsColors::from_string(&env_to_string(
|
||||
"LS_COLORS",
|
||||
v,
|
||||
engine_state,
|
||||
stack,
|
||||
&config,
|
||||
)?),
|
||||
None => LsColors::default(),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user