diff --git a/source/cli/mod.rs b/source/cli/mod.rs index ab2590b..fcdc333 100644 --- a/source/cli/mod.rs +++ b/source/cli/mod.rs @@ -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 { diff --git a/source/cli/run.rs b/source/cli/run.rs index ee9258f..0bc5aa8 100644 --- a/source/cli/run.rs +++ b/source/cli/run.rs @@ -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 {