Skip to content

Commit

Permalink
[fix] making pcode file type optional with the associated error if mi…
Browse files Browse the repository at this point in the history
…ssing during pcode processing
  • Loading branch information
br0kej committed Sep 12, 2024
1 parent cbd73cd commit 869e9d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ enum GenerateSubCommands {
/// Determine the pcode filetype
#[arg(long, value_parser = clap::builder::PossibleValuesParser::new(["pcode-func", "pcode-bb"])
.map(|s| s.parse::<String>().unwrap()))]
pcode_file_format: String,
pcode_file_format: Option<String>,
},
/// Generate metadata/feature subsets from extracted data
Metadata {
Expand Down Expand Up @@ -895,6 +895,10 @@ fn main() {
_ => InstructionMode::Invalid,
};

if instruction_type == InstructionMode::PCode && pcode_file_format.is_none() {
error!("--pcode-file-format is required when processed PCode")
}

if instruction_type == InstructionMode::Invalid {
error!("Invalid instruction mode: {:?}", instruction_type);
exit(1)
Expand Down Expand Up @@ -939,7 +943,7 @@ fn main() {
)
}
InstructionMode::PCode => {
let pcode_file_type = match pcode_file_format.as_str() {
let pcode_file_type = match pcode_file_format.as_ref().unwrap().as_str() {
"pcode-func" => PCodeFileTypes::PCodeJsonFile,
"pcode-bb" => PCodeFileTypes::PCodeWithBBFile,
_ => unreachable!("Invalid PCode file type"),
Expand Down

0 comments on commit 869e9d8

Please sign in to comment.