2023-08-03 18:06:00 +00:00
|
|
|
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,
|
2023-12-15 06:32:37 +00:00
|
|
|
"The desired date format.",
|
2023-08-03 18:06:00 +00:00
|
|
|
)
|
2023-08-14 19:17:31 +00:00
|
|
|
.category(Category::Removed)
|
2023-08-03 18:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
2023-12-10 14:28:54 +00:00
|
|
|
"Removed command: use `format date` instead."
|
2023-08-03 18:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
_engine_state: &EngineState,
|
|
|
|
_stack: &mut Stack,
|
|
|
|
call: &Call,
|
|
|
|
_input: PipelineData,
|
|
|
|
) -> Result<PipelineData, ShellError> {
|
2023-12-10 00:46:21 +00:00
|
|
|
Err(nu_protocol::ShellError::RemovedCommand {
|
|
|
|
removed: self.name().to_string(),
|
|
|
|
replacement: "format date".to_owned(),
|
|
|
|
span: call.head,
|
|
|
|
})
|
2023-08-03 18:06:00 +00:00
|
|
|
}
|
|
|
|
}
|