Add the date subcommand.
This commit is contained in:
parent
8278ffbcbd
commit
1a20348bf1
|
@ -27,6 +27,13 @@ pub enum MainSubcommand {
|
|||
command: ArgumentsSubcommand,
|
||||
},
|
||||
|
||||
/// The date subcommand.
|
||||
Date {
|
||||
/// The date subcommands.
|
||||
#[command(subcommand)]
|
||||
command: DateSubcommand,
|
||||
},
|
||||
|
||||
/// The directory subcommand.
|
||||
Directory {
|
||||
/// The directory subcommands.
|
||||
|
@ -75,6 +82,17 @@ pub enum ArgumentsSubcommand {
|
|||
},
|
||||
}
|
||||
|
||||
/// The date subcommands.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum DateSubcommand {
|
||||
/// Gets the current date.
|
||||
Now {
|
||||
/// The format string for the date, defaults to ISO 8601.
|
||||
#[arg(short, long, default_value = "%FT%T%z")]
|
||||
format: String,
|
||||
},
|
||||
}
|
||||
|
||||
/// The directory subcommands.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum DirectorySubcommand {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
use {
|
||||
crate::{
|
||||
cli::{
|
||||
ArgumentsSubcommand, Cli, DirectorySubcommand, FileSubcommand,
|
||||
MainSubcommand::*, MatchSubcommand, Parser,
|
||||
ArgumentsSubcommand, Cli, DateSubcommand, DirectorySubcommand,
|
||||
FileSubcommand, MainSubcommand::*, MatchSubcommand, Parser,
|
||||
},
|
||||
logging::append_line_to_file,
|
||||
},
|
||||
|
@ -30,6 +30,14 @@ pub fn run() {
|
|||
}
|
||||
},
|
||||
|
||||
Date {
|
||||
command: date_subcommand,
|
||||
} => match date_subcommand {
|
||||
DateSubcommand::Now { format } => {
|
||||
print!("{}", Local::now().format(&format));
|
||||
}
|
||||
},
|
||||
|
||||
Directory {
|
||||
command: directory_subcommand,
|
||||
} => match directory_subcommand {
|
||||
|
|
Loading…
Reference in New Issue