Refactor/config commands (#3265)

* Use ctx.configs in all config commands

* Remove all setting/accessing of  vars.("config-path")

* Add tests

* Add comment

* Reload cfg on remove

* Hypocratic ws change

* Use history_path in hist_or_default

* Make clippy happy

* Fix rebase stuff

* Fix clippy lint
This commit is contained in:
Leonhard Kipp
2021-04-09 08:03:12 +02:00
committed by GitHub
parent 111ad868a7
commit ac070ae942
19 changed files with 357 additions and 254 deletions

View File

@ -173,7 +173,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
let _ = configure_rustyline_editor(&mut rl, cfg);
let helper = Some(nu_line_editor_helper(&context, cfg));
rl.set_helper(helper);
nu_data::config::path::history_path(cfg)
nu_data::config::path::history_path_or_default(cfg)
} else {
nu_data::config::path::default_history_path()
};
@ -420,15 +420,8 @@ pub fn load_local_cfg_if_present(context: &EvaluationContext) {
}
fn load_cfg_as_global_cfg(context: &EvaluationContext, path: PathBuf) {
if let Err(err) = context.load_config(&ConfigPath::Global(path.clone())) {
if let Err(err) = context.load_config(&ConfigPath::Global(path)) {
context.host.lock().print_err(err, &Text::from(""));
} else {
//TODO current commands assume to find path to global cfg file under config-path
//TODO use newly introduced nuconfig::file_path instead
context.scope.add_var(
"config-path",
UntaggedValue::filepath(path).into_untagged_value(),
);
}
}