Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions rule-preprocessor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ use semantic::SemanticAnalysis;
use syntactic::SyntacticAnalysis;

fn main() {
let out_dir = std::env::args()
.nth(1)
.expect("usage: rule-preprocessor <out-dir>");
let mut args = std::env::args().skip(1);
let out_dir = args
.next()
.expect("usage: rule-preprocessor <out-dir> [rules-crate-dir]");
let in_dir = args.next().unwrap_or_else(|| "../rules".to_string());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should terminate the program if the dir is not found. Otherwise it will create confusion when someone wants to use dir X and instead it fallbacks to rules/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback to ../rules only happens when the argument is not provided, i.e., it acts as a default argument. If the provided directory is not found, the program terminates with a No such file or directory error.

SemanticAnalysis::run(SyntacticAnalysis::run(
&std::fs::canonicalize("../rules").unwrap(),
&std::fs::canonicalize(&in_dir).unwrap(),
))
.write_ir(&std::path::PathBuf::from(out_dir));
}
Loading