Skip to content

Commit

Permalink
Syntax refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
rachancheet committed Feb 29, 2024
1 parent 5e31306 commit 4c9918b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions wayshot/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ pub struct Cli {
/// Uses time stamp(%H:%M:%S) as file name
#[arg(short, long)]
pub time_stamp: bool,

/// Arguments to call slurp with for selecting a region
#[arg(short, long, value_name = "folder")]
pub folder: Option<PathBuf>,
}
8 changes: 3 additions & 5 deletions wayshot/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,19 @@ pub fn get_default_file_name(extension: EncodingFormat) -> PathBuf {

fn get_hour_minute_from_unix_seconds(seconds: u64) -> String {
let total_minutes = seconds / 60;

let mut current_hour = (((total_minutes / 60) % 24) + 5) % 24;

let mut current_minute = (total_minutes % 60) + 30;
// println!("{}", current_minute);

if current_minute > 60 {
current_hour += 1;
}

current_minute = current_minute % 60;

if current_hour == 24 {
current_hour = 0;
}

// println!("{}", total_minutes as f64 / 60.0);

format!("{}:{}:{}", current_hour, current_minute, seconds % 60)
}
pub fn get_time_stamp_file_name(extension: EncodingFormat) -> PathBuf {
Expand Down
18 changes: 15 additions & 3 deletions wayshot/src/wayshot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
io::{stdout, BufWriter, Cursor, Write},
path::PathBuf,
process::Command,
};

Expand Down Expand Up @@ -61,11 +62,22 @@ fn main() -> Result<()> {
}
}
None => {
if (cli.time_stamp) {
Some(utils::get_time_stamp_file_name(requested_encoding))
let mut temp = PathBuf::new();
match cli.folder {
Some(path) => {
temp.push(path);
}
None => {
"";
}
}
if cli.time_stamp {
temp.push(utils::get_time_stamp_file_name(requested_encoding));
} else {
Some(utils::get_default_file_name(requested_encoding))
temp.push(utils::get_default_file_name(requested_encoding));
}

Some(temp)
}
};

Expand Down

0 comments on commit 4c9918b

Please sign in to comment.