forked from extern/nushell
remove nu_cli crate dependency from nu_std (#8807)
now nu_std only depends on nu_parser, nu_protocol and miette and removes the nu_cli dependency this enables developers moving forward to come along and implement their own CLI's without having to pull in a redundant nu-cli which will not be needed for them. I did this by moving report_error into nu_protocol which nu_std already has a dependency on anyway.... - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ```
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::engine::StateWorkingSet;
|
||||
use crate::engine::{EngineState, StateWorkingSet};
|
||||
use miette::{LabeledSpan, MietteHandlerOpts, ReportHandler, RgbColors, Severity, SourceCode};
|
||||
use thiserror::Error;
|
||||
|
||||
@ -18,6 +18,27 @@ pub fn format_error(
|
||||
format!("Error: {:?}", CliError(error, working_set))
|
||||
}
|
||||
|
||||
pub fn report_error(
|
||||
working_set: &StateWorkingSet,
|
||||
error: &(dyn miette::Diagnostic + Send + Sync + 'static),
|
||||
) {
|
||||
eprintln!("Error: {:?}", CliError(error, working_set));
|
||||
// reset vt processing, aka ansi because illbehaved externals can break it
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let _ = nu_utils::enable_vt_processing();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn report_error_new(
|
||||
engine_state: &EngineState,
|
||||
error: &(dyn miette::Diagnostic + Send + Sync + 'static),
|
||||
) {
|
||||
let working_set = StateWorkingSet::new(engine_state);
|
||||
|
||||
report_error(&working_set, error);
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for CliError<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let ansi_support = self.1.get_config().use_ansi_coloring;
|
||||
|
@ -1,6 +1,6 @@
|
||||
mod alias;
|
||||
pub mod ast;
|
||||
mod cli_error;
|
||||
pub mod cli_error;
|
||||
pub mod config;
|
||||
pub mod engine;
|
||||
mod example;
|
||||
|
Reference in New Issue
Block a user