mirror of
https://github.com/nushell/nushell.git
synced 2025-04-28 23:28:20 +02:00
Remove to xml --pretty
(#10668)
followup to - https://github.com/nushell/nushell/pull/10660
This commit is contained in:
parent
de1c7bb39f
commit
999f7b229f
@ -4,8 +4,8 @@ use nu_engine::CallExt;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
report_error_new, Category, Example, IntoPipelineData, PipelineData, Record, ShellError,
|
Category, Example, IntoPipelineData, PipelineData, Record, ShellError, Signature, Span,
|
||||||
Signature, Span, Spanned, SyntaxShape, Type, Value,
|
Spanned, SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event};
|
use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
@ -22,12 +22,6 @@ impl Command for ToXml {
|
|||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("to xml")
|
Signature::build("to xml")
|
||||||
.input_output_types(vec![(Type::Record(vec![]), Type::String)])
|
.input_output_types(vec![(Type::Record(vec![]), Type::String)])
|
||||||
.named(
|
|
||||||
"pretty",
|
|
||||||
SyntaxShape::Int,
|
|
||||||
"DEPRECATED option, will be removed in 0.87. Please use `--indent {int}` instead.",
|
|
||||||
Some('p'),
|
|
||||||
)
|
|
||||||
.named(
|
.named(
|
||||||
"indent",
|
"indent",
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Int,
|
||||||
@ -86,33 +80,7 @@ Additionally any field which is: empty record, empty list or null, can be omitte
|
|||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let head = call.head;
|
let head = call.head;
|
||||||
if call.has_flag("pretty") {
|
|
||||||
report_error_new(
|
|
||||||
engine_state,
|
|
||||||
&ShellError::GenericError(
|
|
||||||
"Deprecated option".into(),
|
|
||||||
"`to xml --pretty {int}` is deprecated and will be removed in 0.87.".into(),
|
|
||||||
Some(call.head),
|
|
||||||
Some("Please use `--indent {int}` instead.".into()),
|
|
||||||
vec![],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let pretty: Option<Spanned<i64>> = call.get_flag(engine_state, stack, "pretty")?;
|
|
||||||
let indent: Option<Spanned<i64>> = call.get_flag(engine_state, stack, "indent")?;
|
let indent: Option<Spanned<i64>> = call.get_flag(engine_state, stack, "indent")?;
|
||||||
let indent = match (pretty, indent) {
|
|
||||||
(Some(pretty), Some(indent)) => {
|
|
||||||
return Err(ShellError::IncompatibleParameters {
|
|
||||||
left_message: "Cannot pass --pretty".into(),
|
|
||||||
left_span: pretty.span,
|
|
||||||
right_message: "and --indent".into(),
|
|
||||||
right_span: indent.span,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
(Some(pretty), None) => Some(pretty),
|
|
||||||
(None, Some(indent)) => Some(indent),
|
|
||||||
(None, None) => None,
|
|
||||||
};
|
|
||||||
let input = input.try_expand_range()?;
|
let input = input.try_expand_range()?;
|
||||||
to_xml(input, head, indent)
|
to_xml(input, head, indent)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user