Skip to content

Commit

Permalink
cli: add --check-equally-applicable-rules flag
Browse files Browse the repository at this point in the history
Add --check-equally-applicable-rules and
--no-check-equally-applicable-rules flags to enable / disable the naive
rewriters multiple equally applicable rules assertion via the
command line.

As before, this assertion is disabled by default.

Issue: #552
  • Loading branch information
niklasdewally committed Jan 16, 2025
1 parent 0bf7362 commit 1f3828a
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions conjure_oxide/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,39 @@ struct Cli {
#[arg(long, help = "Save execution info as JSON to the given file-path.")]
info_json_path: Option<PathBuf>,

#[arg(
long,
short = 'o',
help = "Save solutions to a JSON file (prints to stdin by default)"
)]
#[arg(
long,
help = "use the, in development, dirty-clean optimising rewriter",
default_value_t = false
)]
use_optimising_rewriter: bool,

#[arg(
long,
short = 'o',
help = "Save solutions to a JSON file (prints to stdout by default)"
)]
output: Option<PathBuf>,

#[arg(long, short = 'v', help = "Log verbosely to sterr")]
verbose: bool,

// --no-x flag disables --x flag : https://jwodder.github.io/kbits/posts/clap-bool-negate/
/// Check for multiple equally applicable rules, exiting if any are found.
///
/// Only compatible with the default rewriter.
#[arg(
long,
overrides_with = "_no_check_equally_applicable_rules",
default_value_t = false
)]
check_equally_applicable_rules: bool,

/// Do not check for multiple equally applicable rules [default].
///
/// Only compatible with the default rewriter.
#[arg(long)]
_no_check_equally_applicable_rules: bool,
}

#[allow(clippy::unwrap_used)]
Expand Down Expand Up @@ -266,7 +283,7 @@ pub fn main() -> AnyhowResult<()> {
model = rewrite_model(&model, &rule_sets)?;
} else {
tracing::info!("Rewriting model...");
model = rewrite_naive(&model, &rule_sets, false)?;
model = rewrite_naive(&model, &rule_sets, cli.check_equally_applicable_rules)?;
}

tracing::info!("Rewritten model: \n{}\n", model);
Expand Down

0 comments on commit 1f3828a

Please sign in to comment.