Add the date subcommand.
This commit is contained in:
parent
8278ffbcbd
commit
1a20348bf1
|
@ -27,6 +27,13 @@ pub enum MainSubcommand {
|
||||||
command: ArgumentsSubcommand,
|
command: ArgumentsSubcommand,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// The date subcommand.
|
||||||
|
Date {
|
||||||
|
/// The date subcommands.
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: DateSubcommand,
|
||||||
|
},
|
||||||
|
|
||||||
/// The directory subcommand.
|
/// The directory subcommand.
|
||||||
Directory {
|
Directory {
|
||||||
/// The directory subcommands.
|
/// 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.
|
/// The directory subcommands.
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum DirectorySubcommand {
|
pub enum DirectorySubcommand {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
cli::{
|
cli::{
|
||||||
ArgumentsSubcommand, Cli, DirectorySubcommand, FileSubcommand,
|
ArgumentsSubcommand, Cli, DateSubcommand, DirectorySubcommand,
|
||||||
MainSubcommand::*, MatchSubcommand, Parser,
|
FileSubcommand, MainSubcommand::*, MatchSubcommand, Parser,
|
||||||
},
|
},
|
||||||
logging::append_line_to_file,
|
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 {
|
Directory {
|
||||||
command: directory_subcommand,
|
command: directory_subcommand,
|
||||||
} => match directory_subcommand {
|
} => match directory_subcommand {
|
||||||
|
|
Loading…
Reference in New Issue