Skip to content

Commit

Permalink
Verify every dependency is required (#65)
Browse files Browse the repository at this point in the history
If not, the generated code will not work

Fixes #64
  • Loading branch information
mart-e authored Dec 3, 2024
1 parent 252262e commit f886389
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update the resulting binary name (#62)

### Fixed
- Verify the required options are provided (#65)

### Removed

Expand Down
19 changes: 19 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ impl GeneratorOptionItem {
GeneratorOptionItem::Option(option) => option.chips,
}
}

fn enables(&self) -> &[&str] {
match self {
GeneratorOptionItem::Category(_) => &[],
GeneratorOptionItem::Option(option) => option.enables,
}
}
}

static OPTIONS: &[GeneratorOptionItem] = &[
Expand Down Expand Up @@ -469,6 +476,18 @@ fn process_options(args: &Args) {
);
process::exit(-1);
}
if !option_item
.enables()
.iter()
.all(|requirement| args.option.contains(&requirement.to_string()))
{
log::error!(
"Option '{}' requires {}",
option_item.name(),
option_item.enables().join(", ")
);
process::exit(-1);
}
}
}
}
Expand Down

0 comments on commit f886389

Please sign in to comment.