Skip to content

Commit

Permalink
Fix file cli file argument behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigas002 committed Apr 1, 2024
1 parent 3cce69d commit 629d380
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wayshot/src/wayshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() -> Result<()> {
let cursor = cli.cursor.unwrap_or(screenshot.cursor.unwrap_or_default());
let clipboard = cli
.clipboard
.unwrap_or(screenshot.clipboard.unwrap_or(true));
.unwrap_or(screenshot.clipboard.unwrap_or_default());
let filename_format = cli
.filename_format
.unwrap_or(fs.format.unwrap_or("wayshot-%Y_%m_%d-%H_%M_%S".to_string()));
Expand Down Expand Up @@ -81,16 +81,21 @@ fn main() -> Result<()> {

let stdout_print = cli.stdout.unwrap_or(screenshot.stdout.unwrap_or_default());
let file = match cli.file {
Some(f) => {
Some(mut f) => {
if f.is_dir() {
Some(utils::get_full_file_name(&f, &filename_format, encoding))
} else {
Some(utils::get_checked_path(f.to_str().unwrap_or_default()))
f.set_extension("");
let dir = fs.path.unwrap_or(env::current_dir().unwrap_or_default());
Some(utils::get_full_file_name(
&dir,
&f.to_str().unwrap(),
encoding,
))
}
}
_ => {
if screenshot.fs.unwrap_or_default() {
// default to current dir
let dir = fs.path.unwrap_or(env::current_dir().unwrap_or_default());
Some(utils::get_full_file_name(&dir, &filename_format, encoding))
} else {
Expand Down

0 comments on commit 629d380

Please sign in to comment.