mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:07:57 +02:00
Refactor the CLI code a bit (#12782)
# Description Refactors the code in `nu-cli`, `main.rs`, `run.rs`, and few others. Namely, I added `EngineState::generate_nu_constant` function to eliminate some duplicate code. Otherwise, I changed a bunch of areas to return errors instead of calling `std::process::exit`. # User-Facing Changes Should be none.
This commit is contained in:
@ -32,7 +32,7 @@ enum ConversionResult {
|
||||
/// It returns Option instead of Result since we do want to translate all the values we can and
|
||||
/// skip errors. This function is called in the main() so we want to keep running, we cannot just
|
||||
/// exit.
|
||||
pub fn convert_env_values(engine_state: &mut EngineState, stack: &Stack) -> Option<ShellError> {
|
||||
pub fn convert_env_values(engine_state: &mut EngineState, stack: &Stack) -> Result<(), ShellError> {
|
||||
let mut error = None;
|
||||
|
||||
let mut new_scope = HashMap::new();
|
||||
@ -85,7 +85,11 @@ pub fn convert_env_values(engine_state: &mut EngineState, stack: &Stack) -> Opti
|
||||
});
|
||||
}
|
||||
|
||||
error
|
||||
if let Some(err) = error {
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate one environment variable from Value to String
|
||||
|
Reference in New Issue
Block a user