forked from extern/nushell
Refactor nu-cli/env* (#3041)
* Revert "History, more test coverage improvements, and refactorings. (#3217)"
This reverts commit 8fc8fc89aa
.
* Add tests
* Refactor .nu-env
* Change logic of Config write to logic of read()
* Fix reload always appends to old vars
* Fix reload always takes last_modified of global config
* Add reload_config in evaluation context
* Reload config after writing to it in cfg set / cfg set_into
* Add --no-history to cli options
* Use --no-history in tests
* Add comment about maybe_print_errors
* Get ctrl_exit var from context.global_config
* Use context.global_config in command "config"
* Add Readme in engine how env vars are now handled
* Update docs from autoenv command
* Move history_path from engine to nu_data
* Move load history out of if
* No let before return
* Add import for indexmap
This commit is contained in:
19
crates/nu-protocol/src/config_path.rs
Normal file
19
crates/nu-protocol/src/config_path.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Specifies a path to a configuration file and its type
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub enum ConfigPath {
|
||||
/// Path to the global configuration file
|
||||
Global(PathBuf),
|
||||
/// Path to a local configuration file
|
||||
Local(PathBuf),
|
||||
}
|
||||
|
||||
impl ConfigPath {
|
||||
pub fn get_path(&self) -> &PathBuf {
|
||||
match self {
|
||||
ConfigPath::Global(p) | ConfigPath::Local(p) => p,
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
mod macros;
|
||||
|
||||
mod call_info;
|
||||
pub mod config_path;
|
||||
pub mod hir;
|
||||
mod maybe_owned;
|
||||
mod return_value;
|
||||
@ -12,6 +13,7 @@ mod type_shape;
|
||||
pub mod value;
|
||||
|
||||
pub use crate::call_info::{CallInfo, EvaluatedArgs};
|
||||
pub use crate::config_path::ConfigPath;
|
||||
pub use crate::maybe_owned::MaybeOwned;
|
||||
pub use crate::return_value::{CommandAction, ReturnSuccess, ReturnValue};
|
||||
pub use crate::signature::{NamedType, PositionalType, Signature};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::value::Value;
|
||||
use crate::{value::Value, ConfigPath};
|
||||
use nu_errors::ShellError;
|
||||
use nu_source::{DbgDocBldr, DebugDocBuilder, PrettyDebug};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -22,6 +22,10 @@ pub enum CommandAction {
|
||||
EnterHelpShell(Value),
|
||||
/// Add plugins from path given
|
||||
AddPlugins(String),
|
||||
/// Unload the config specified by PathBuf if present
|
||||
UnloadConfig(ConfigPath),
|
||||
/// Load the config specified by PathBuf
|
||||
LoadConfig(ConfigPath),
|
||||
/// Go to the previous shell in the shell ring buffer
|
||||
PreviousShell,
|
||||
/// Go to the next shell in the shell ring buffer
|
||||
@ -51,6 +55,12 @@ impl PrettyDebug for CommandAction {
|
||||
CommandAction::PreviousShell => DbgDocBldr::description("previous shell"),
|
||||
CommandAction::NextShell => DbgDocBldr::description("next shell"),
|
||||
CommandAction::LeaveShell(_) => DbgDocBldr::description("leave shell"),
|
||||
CommandAction::UnloadConfig(cfg) => {
|
||||
DbgDocBldr::description(format!("unload config {:?}", cfg))
|
||||
}
|
||||
CommandAction::LoadConfig(cfg) => {
|
||||
DbgDocBldr::description(format!("load config {:?}", cfg))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user