Skip to content

Commit

Permalink
CLI: auto-provide extension and warn if it's wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed Oct 31, 2024
1 parent 905c139 commit b52be46
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/gui/src/bin/ntsc-rs-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub fn main() -> Result<()> {
let input_path = matches
.get_one::<PathBuf>("input")
.expect("input path is present");
let output_path = matches
let mut output_path = matches
.get_one::<PathBuf>("output")
.expect("output path is present")
.to_owned();
Expand Down Expand Up @@ -309,6 +309,24 @@ pub fn main() -> Result<()> {
)?;
term.flush()?;

if output_path.extension().is_none() {
output_path.set_extension(codec.extension());
}

if let Some(extension) = output_path.extension() {
if extension != codec.extension() {
writeln!(
term,
"{}",
style(format!(
"Warning: the provided output file name's extension (.{}) does not match the file extension for the container being used (.{})",
extension.to_string_lossy(),
codec.extension()
)).yellow()
)?;
}
}

if let (Ok(true), false) = (output_path.try_exists(), overwrite) {
let should_exit = if term.is_term() {
loop {
Expand Down

0 comments on commit b52be46

Please sign in to comment.