Skip to content

Commit

Permalink
user-friendly errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aneksteind committed Nov 13, 2023
1 parent 0ea8aea commit 34106d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions c2rust/src/bin/c2rust-transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,18 @@ fn main() {
let compile_commands = if args.compile_commands.len() == 1
&& args.compile_commands[0].extension() == Some(std::ffi::OsStr::new("json"))
{
// Only one file provided and it's a JSON file
// Only one file provided and it's a compile commands JSON file
args.compile_commands[0].clone()
} else if args
.compile_commands
.iter()
.any(|path| path.extension() == Some(std::ffi::OsStr::new("json")))
{
// More than one file provided and at least one is a JSON file
panic!("Compile commands JSON and multiple sources provided.
Exactly one compile_commands.json file should be provided, or a list of source files, but not both.");
} else {
// Otherwise, handle as a list of source files
// Handle as a list of source files
c2rust_transpile::create_temp_compile_commands(&args.compile_commands)
};

Expand Down

0 comments on commit 34106d9

Please sign in to comment.