nushell/crates/nu-command/src/removed/format.rs
Stefan Holderbach 435348aa61
Rename misused "deprecation" to removal (#10000)
# Description
In the past we named the process of completely removing a command and
providing a basic error message pointing to the new alternative
"deprecation".

But this doesn't match the expectation of most users that have seen
deprecation _warnings_ that alert to either impending removal or
discouraged use after a stability promise.

# User-Facing Changes
Command category changed from `deprecated` to `removed`
2023-08-15 07:17:31 +12:00

47 lines
1.3 KiB
Rust

use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct SubCommand;
impl Command for SubCommand {
fn name(&self) -> &str {
"date format"
}
fn signature(&self) -> Signature {
Signature::build("date format")
.input_output_types(vec![
(Type::Date, Type::String),
(Type::String, Type::String),
])
.allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032
.switch("list", "lists strftime cheatsheet", Some('l'))
.optional(
"format string",
SyntaxShape::String,
"the desired date format",
)
.category(Category::Removed)
}
fn usage(&self) -> &str {
"Removed command: use `format date` instead"
}
fn run(
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
Err(nu_protocol::ShellError::RemovedCommand(
self.name().to_string(),
"format date".to_owned(),
call.head,
))
}
}