Skip to content

Commit f886389

Browse files
authored
Verify every dependency is required (#65)
If not, the generated code will not work Fixes #64
1 parent 252262e commit f886389

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Update the resulting binary name (#62)
1414

1515
### Fixed
16+
- Verify the required options are provided (#65)
1617

1718
### Removed
1819

src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ impl GeneratorOptionItem {
8383
GeneratorOptionItem::Option(option) => option.chips,
8484
}
8585
}
86+
87+
fn enables(&self) -> &[&str] {
88+
match self {
89+
GeneratorOptionItem::Category(_) => &[],
90+
GeneratorOptionItem::Option(option) => option.enables,
91+
}
92+
}
8693
}
8794

8895
static OPTIONS: &[GeneratorOptionItem] = &[
@@ -469,6 +476,18 @@ fn process_options(args: &Args) {
469476
);
470477
process::exit(-1);
471478
}
479+
if !option_item
480+
.enables()
481+
.iter()
482+
.all(|requirement| args.option.contains(&requirement.to_string()))
483+
{
484+
log::error!(
485+
"Option '{}' requires {}",
486+
option_item.name(),
487+
option_item.enables().join(", ")
488+
);
489+
process::exit(-1);
490+
}
472491
}
473492
}
474493
}

0 commit comments

Comments
 (0)