Deprecate group
command
This commit is contained in:
parent
6818e1e472
commit
fe01534201
|
@ -1,5 +1,5 @@
|
||||||
use nu_engine::command_prelude::*;
|
use nu_engine::command_prelude::*;
|
||||||
use nu_protocol::ValueIterator;
|
use nu_protocol::{report_warning_new, ParseWarning, ValueIterator};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Group;
|
pub struct Group;
|
||||||
|
@ -54,6 +54,17 @@ impl Command for Group {
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let head = call.head;
|
let head = call.head;
|
||||||
|
|
||||||
|
report_warning_new(
|
||||||
|
engine_state,
|
||||||
|
&ParseWarning::DeprecatedWarning {
|
||||||
|
old_command: "group".into(),
|
||||||
|
new_suggestion: "the new `chunks` command".into(),
|
||||||
|
span: head,
|
||||||
|
url: "`help chunks`".into(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let group_size: Spanned<usize> = call.req(engine_state, stack, 0)?;
|
let group_size: Spanned<usize> = call.req(engine_state, stack, 0)?;
|
||||||
let metadata = input.metadata();
|
let metadata = input.metadata();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,26 @@ pub fn report_error_new(
|
||||||
report_error(&working_set, error);
|
report_error(&working_set, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn report_warning(
|
||||||
|
working_set: &StateWorkingSet,
|
||||||
|
error: &(dyn miette::Diagnostic + Send + Sync + 'static),
|
||||||
|
) {
|
||||||
|
eprintln!("Warning: {:?}", 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_warning_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<'_> {
|
impl std::fmt::Debug for CliError<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let config = self.1.get_config();
|
let config = self.1.get_config();
|
||||||
|
|
|
@ -5,7 +5,9 @@ mod parse_error;
|
||||||
mod parse_warning;
|
mod parse_warning;
|
||||||
mod shell_error;
|
mod shell_error;
|
||||||
|
|
||||||
pub use cli_error::{format_error, report_error, report_error_new};
|
pub use cli_error::{
|
||||||
|
format_error, report_error, report_error_new, report_warning, report_warning_new,
|
||||||
|
};
|
||||||
pub use compile_error::CompileError;
|
pub use compile_error::CompileError;
|
||||||
pub use labeled_error::{ErrorLabel, LabeledError};
|
pub use labeled_error::{ErrorLabel, LabeledError};
|
||||||
pub use parse_error::{DidYouMean, ParseError};
|
pub use parse_error::{DidYouMean, ParseError};
|
||||||
|
|
|
@ -6,11 +6,11 @@ use thiserror::Error;
|
||||||
#[derive(Clone, Debug, Error, Diagnostic, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Error, Diagnostic, Serialize, Deserialize)]
|
||||||
pub enum ParseWarning {
|
pub enum ParseWarning {
|
||||||
#[error("Deprecated: {old_command}")]
|
#[error("Deprecated: {old_command}")]
|
||||||
#[diagnostic(help("for more info: {url}"))]
|
#[diagnostic(help("for more info see {url}"))]
|
||||||
DeprecatedWarning {
|
DeprecatedWarning {
|
||||||
old_command: String,
|
old_command: String,
|
||||||
new_suggestion: String,
|
new_suggestion: String,
|
||||||
#[label("`{old_command}` is deprecated and will be removed in a future release. Please {new_suggestion} instead")]
|
#[label("`{old_command}` is deprecated and will be removed in a future release. Please {new_suggestion} instead.")]
|
||||||
span: Span,
|
span: Span,
|
||||||
url: String,
|
url: String,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user