Skip to content

Commit

Permalink
wayshot-{timestamp}.{extension} as default filename
Browse files Browse the repository at this point in the history
  • Loading branch information
rachancheet committed Mar 21, 2024
1 parent 44b11d7 commit 80c1f86
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
4 changes: 0 additions & 4 deletions wayshot/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
16 changes: 1 addition & 15 deletions wayshot/src/utils.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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> = Local::now();
let formated_time = format!("{}", current_datetime.format("%Y_%m_%d-%H_%M_%S"));

Expand Down
8 changes: 1 addition & 7 deletions wayshot/src/wayshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 80c1f86

Please sign in to comment.