From 80c1f86ebd96df00b9d2a568211e2781dd8269be Mon Sep 17 00:00:00 2001 From: rachancheet Date: Thu, 21 Mar 2024 21:21:53 +0530 Subject: [PATCH] wayshot-{timestamp}.{extension} as default filename --- wayshot/src/cli.rs | 4 ---- wayshot/src/utils.rs | 16 +--------------- wayshot/src/wayshot.rs | 8 +------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/wayshot/src/cli.rs b/wayshot/src/cli.rs index 749c4801..418ac8d8 100644 --- a/wayshot/src/cli.rs +++ b/wayshot/src/cli.rs @@ -43,8 +43,4 @@ pub struct Cli { /// Present a fuzzy selector for output/display selection #[arg(long, alias = "chooseoutput", conflicts_with_all = ["slurp", "output"])] pub choose_output: bool, - - /// Uses time stamp(%H:%M:%S) as file name - #[arg(short, long)] - pub timestamp: bool, } diff --git a/wayshot/src/utils.rs b/wayshot/src/utils.rs index b11993de..158f997f 100644 --- a/wayshot/src/utils.rs +++ b/wayshot/src/utils.rs @@ -1,12 +1,7 @@ use clap::ValueEnum; use eyre::{bail, ContextCompat, Error, Result}; -use std::{ - fmt::Display, - path::PathBuf, - str::FromStr, - time::{SystemTime, UNIX_EPOCH}, -}; +use std::{fmt::Display, path::PathBuf, str::FromStr}; use chrono::{DateTime, Local}; use libwayshot::region::{LogicalRegion, Position, Region, Size}; @@ -135,15 +130,6 @@ impl FromStr for EncodingFormat { } pub fn get_default_file_name(extension: EncodingFormat) -> PathBuf { - let time = SystemTime::now() - .duration_since(UNIX_EPOCH) - .map(|time| time.as_secs().to_string()) - .unwrap_or("unknown".into()); - - format!("wayshot-{time}.{extension}").into() -} - -pub fn get_time_stamp_file_name(extension: EncodingFormat) -> PathBuf { let current_datetime: DateTime = Local::now(); let formated_time = format!("{}", current_datetime.format("%Y_%m_%d-%H_%M_%S")); diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index bdee6917..37152a79 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -60,13 +60,7 @@ fn main() -> Result<()> { Some(pathbuf) } } - None => { - if cli.timestamp { - Some(utils::get_time_stamp_file_name(requested_encoding)) - } else { - Some(utils::get_default_file_name(requested_encoding)) - } - } + None => Some(utils::get_default_file_name(requested_encoding)), }; let wayshot_conn = WayshotConnection::new()?;