mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
This reverts commit 6dde231dde
.
This commit is contained in:
parent
3676a8a48d
commit
b7d3623e53
2 changed files with 27 additions and 48 deletions
|
@ -18,7 +18,6 @@ pub(crate) fn read_config_file(
|
||||||
config_file: Option<Spanned<String>>,
|
config_file: Option<Spanned<String>>,
|
||||||
is_perf_true: bool,
|
is_perf_true: bool,
|
||||||
is_env_config: bool,
|
is_env_config: bool,
|
||||||
interactive: bool,
|
|
||||||
) {
|
) {
|
||||||
// Load config startup file
|
// Load config startup file
|
||||||
if let Some(file) = config_file {
|
if let Some(file) = config_file {
|
||||||
|
@ -47,13 +46,7 @@ pub(crate) fn read_config_file(
|
||||||
|
|
||||||
config_path.push(if is_env_config { ENV_FILE } else { CONFIG_FILE });
|
config_path.push(if is_env_config { ENV_FILE } else { CONFIG_FILE });
|
||||||
|
|
||||||
let config_file = if is_env_config {
|
if !config_path.exists() {
|
||||||
include_str!("../docs/sample_config/default_env.nu")
|
|
||||||
} else {
|
|
||||||
include_str!("../docs/sample_config/default_config.nu")
|
|
||||||
};
|
|
||||||
|
|
||||||
if !config_path.exists() && interactive {
|
|
||||||
let file_msg = if is_env_config {
|
let file_msg = if is_env_config {
|
||||||
"environment config"
|
"environment config"
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,6 +64,12 @@ pub(crate) fn read_config_file(
|
||||||
.read_line(&mut answer)
|
.read_line(&mut answer)
|
||||||
.expect("Failed to read user input");
|
.expect("Failed to read user input");
|
||||||
|
|
||||||
|
let config_file = if is_env_config {
|
||||||
|
include_str!("../docs/sample_config/default_env.nu")
|
||||||
|
} else {
|
||||||
|
include_str!("../docs/sample_config/default_config.nu")
|
||||||
|
};
|
||||||
|
|
||||||
match answer.to_lowercase().trim() {
|
match answer.to_lowercase().trim() {
|
||||||
"y" | "" => {
|
"y" | "" => {
|
||||||
let mut output = File::create(&config_path).expect("Unable to create file");
|
let mut output = File::create(&config_path).expect("Unable to create file");
|
||||||
|
@ -94,19 +93,6 @@ pub(crate) fn read_config_file(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Just use the contents of "default_config.nu" or "default_env.nu"
|
|
||||||
eval_source(
|
|
||||||
engine_state,
|
|
||||||
stack,
|
|
||||||
config_file.as_bytes(),
|
|
||||||
if is_env_config {
|
|
||||||
"default_env.nu"
|
|
||||||
} else {
|
|
||||||
"default_config.nu"
|
|
||||||
},
|
|
||||||
PipelineData::new(Span::new(0, 0)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eval_config_contents(config_path, engine_state, stack);
|
eval_config_contents(config_path, engine_state, stack);
|
||||||
|
|
47
src/main.rs
47
src/main.rs
|
@ -206,14 +206,6 @@ fn main() -> Result<()> {
|
||||||
is_perf_true(),
|
is_perf_true(),
|
||||||
);
|
);
|
||||||
// only want to load config and env if relative argument is provided.
|
// only want to load config and env if relative argument is provided.
|
||||||
config_files::read_config_file(
|
|
||||||
&mut engine_state,
|
|
||||||
&mut stack,
|
|
||||||
binary_args.env_file,
|
|
||||||
is_perf_true(),
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
if binary_args.config_file.is_some() {
|
if binary_args.config_file.is_some() {
|
||||||
config_files::read_config_file(
|
config_files::read_config_file(
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
|
@ -221,7 +213,15 @@ fn main() -> Result<()> {
|
||||||
binary_args.config_file,
|
binary_args.config_file,
|
||||||
is_perf_true(),
|
is_perf_true(),
|
||||||
false,
|
false,
|
||||||
false,
|
);
|
||||||
|
}
|
||||||
|
if binary_args.env_file.is_some() {
|
||||||
|
config_files::read_config_file(
|
||||||
|
&mut engine_state,
|
||||||
|
&mut stack,
|
||||||
|
binary_args.env_file,
|
||||||
|
is_perf_true(),
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,14 +251,6 @@ fn main() -> Result<()> {
|
||||||
is_perf_true(),
|
is_perf_true(),
|
||||||
);
|
);
|
||||||
// only want to load config and env if relative argument is provided.
|
// only want to load config and env if relative argument is provided.
|
||||||
config_files::read_config_file(
|
|
||||||
&mut engine_state,
|
|
||||||
&mut stack,
|
|
||||||
binary_args.env_file,
|
|
||||||
is_perf_true(),
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
if binary_args.config_file.is_some() {
|
if binary_args.config_file.is_some() {
|
||||||
config_files::read_config_file(
|
config_files::read_config_file(
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
|
@ -266,7 +258,15 @@ fn main() -> Result<()> {
|
||||||
binary_args.config_file,
|
binary_args.config_file,
|
||||||
is_perf_true(),
|
is_perf_true(),
|
||||||
false,
|
false,
|
||||||
false,
|
);
|
||||||
|
}
|
||||||
|
if binary_args.env_file.is_some() {
|
||||||
|
config_files::read_config_file(
|
||||||
|
&mut engine_state,
|
||||||
|
&mut stack,
|
||||||
|
binary_args.env_file,
|
||||||
|
is_perf_true(),
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,15 +323,8 @@ fn setup_config(
|
||||||
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
||||||
}
|
}
|
||||||
|
|
||||||
config_files::read_config_file(engine_state, stack, env_file, is_perf_true(), true, true);
|
config_files::read_config_file(engine_state, stack, env_file, is_perf_true(), true);
|
||||||
config_files::read_config_file(
|
config_files::read_config_file(engine_state, stack, config_file, is_perf_true(), false);
|
||||||
engine_state,
|
|
||||||
stack,
|
|
||||||
config_file,
|
|
||||||
is_perf_true(),
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if is_login_shell {
|
if is_login_shell {
|
||||||
config_files::read_loginshell_file(engine_state, stack, is_perf_true());
|
config_files::read_loginshell_file(engine_state, stack, is_perf_true());
|
||||||
|
|
Loading…
Reference in a new issue