1
use std::path::PathBuf;
2

            
3
use clap::{ArgAction, Args, Parser, Subcommand, ValueEnum};
4

            
5
use clap_complete::Shell;
6
use conjure_cp::settings::{
7
    Channelling, DEFAULT_HEURISTIC_SEED, Heuristic, Parser as InputParser, QuantifiedExpander,
8
    Rewriter, SolverFamily,
9
};
10
use conjure_cp::solver::adaptors::{MinionValueOrder, MinionVariableOrder, SatBackend};
11
use git_version::git_version;
12

            
13
use crate::{pretty, solve, test_solve};
14

            
15
pub(crate) const LOGGING_HELP_HEADING: Option<&str> = Some("Logging & Output");
16
pub(crate) const CONFIGURATION_HELP_HEADING: Option<&str> = Some("Configuration");
17
pub(crate) const MODELLING_HELP_HEADING: Option<&str> = Some("Modelling choices");
18

            
19
/// All subcommands of conjure-oxide
20
#[derive(Clone, Debug, Subcommand)]
21
pub enum Command {
22
    /// Solve a model
23
    Solve(solve::Args),
24
    /// Tests whether the Essence model is solvable with Conjure Oxide, and whether it gets the
25
    /// same solutions as Conjure.
26
    ///
27
    /// Return-code will be 0 if the solutions match, 1 if they don't, and >1 on crash.
28
    TestSolve(test_solve::Args),
29
    /// Generate a completion script for the shell provided
30
    Completion(CompletionArgs),
31
    Pretty(pretty::Args),
32
    // Run the language server
33
    ServerLSP,
34
}
35

            
36
/// Global command line arguments.
37
#[derive(Clone, Debug, Parser)]
38
#[command(
39
    author,
40
    about = "Conjure Oxide: Automated Constraints Modelling Toolkit",
41
    before_help = "Full documentation can be found online at: https://conjure-cp.github.io/conjure-oxide",
42
    // Free `-h` for `--heuristic`; help remains available as `--help`.
43
    disable_help_flag = true,
44
    version = git_version!(),
45
    disable_version_flag = true,
46
    display_name = "conjure-oxide",
47
    // clap's derive turns this on for a required subcommand; keep the concise
48
    // "requires a subcommand" error instead of dumping the full help.
49
    arg_required_else_help = false
50
)]
51
pub struct Cli {
52
    #[command(subcommand)]
53
    pub subcommand: Command,
54

            
55
    #[command(flatten)]
56
    pub global_args: GlobalArgs,
57

            
58
    /// Print version
59
    // `ArgAction::Version` is handled by clap while parsing, so `--version` works on its own,
60
    // without the otherwise-required subcommand.
61
    #[arg(long = "version", short = 'V', action = ArgAction::Version)]
62
    pub version: (),
63
}
64

            
65
#[derive(Debug, Clone, Args)]
66
pub struct GlobalArgs {
67
    /// Print help
68
    #[arg(long, action = clap::ArgAction::Help, global = true)]
69
    pub help: (),
70

            
71
    /// Extra rule sets to enable
72
    #[arg(long, value_name = "EXTRA_RULE_SETS", global = true)]
73
    pub extra_rule_sets: Vec<String>,
74

            
75
    /// Increase stderr logging detail (-v: stages, -vv: rule applications, -vvv: rule attempts).
76
    ///
77
    /// Rule-attempt logging can be expensive and produce a very large amount of output.
78
    #[arg(
79
        long,
80
        short = 'v',
81
        action = ArgAction::Count,
82
        global = true,
83
        conflicts_with = "quiet",
84
        help_heading = LOGGING_HELP_HEADING
85
    )]
86
    pub verbose: u8,
87

            
88
    /// Disable warning and progress logs on stderr
89
    #[arg(long, short = 'q', global = true, help_heading = LOGGING_HELP_HEADING)]
90
    pub quiet: bool,
91

            
92
    /// Output file for the default rule trace.
93
    #[arg(long, global = true, help_heading=LOGGING_HELP_HEADING)]
94
    pub rule_trace: Option<PathBuf>,
95

            
96
    /// Output file for aggregated rule-application counts.
97
    ///
98
    /// Counts are kept in memory and written when the program exits, in the format:
99
    /// `total_rule_applications: N`, followed by one line per rule.
100
    #[arg(long, global = true, help_heading=LOGGING_HELP_HEADING)]
101
    pub rule_trace_aggregates: Option<PathBuf>,
102

            
103
    /// Continue rule trace generation during solver-time CDP rewrites.
104
    ///
105
    /// This is off by default, so follow-up dominance-blocking rewrites do not contribute to the
106
    /// trace.
107
    #[arg(long, default_value_t = false, global = true, help_heading=LOGGING_HELP_HEADING)]
108
    pub rule_trace_cdp: bool,
109

            
110
    /// Output file for the rule-attempt trace in CSV format.
111
    ///
112
    /// Each row includes: elapsed_s, rule_level, rule_name, rule_set, status, expression.
113
    #[arg(
114
        long = "rule-attempt-trace",
115
        global = true,
116
        help_heading=LOGGING_HELP_HEADING
117
    )]
118
    pub rule_attempt_trace: Option<PathBuf>,
119

            
120
    /// Which parser to use.
121
    ///
122
    /// Possible values: `tree-sitter`, `via-conjure`.
123
    #[arg(
124
        long,
125
        default_value_t = InputParser::default(),
126
        value_parser = parse_parser,
127
        global = true,
128
        help_heading = CONFIGURATION_HELP_HEADING
129
    )]
130
    pub parser: InputParser,
131

            
132
    /// Which rewriter to use.
133
    ///
134
    /// Possible values: `baseline`, `optimised`, `baseline+prefilter`, or `baseline+worklist`.
135
    ///
136
    /// Option meanings:
137
    /// - `prefilter`: skip rules whose declared expression kinds cannot match; strong win vs
138
    ///   baseline and part of `optimised`.
139
    /// - `worklist`: drive rewriting from persistent dirty queues instead of repeated full scans;
140
    ///   strong win vs baseline and part of `optimised`.
141
    #[arg(long, default_value_t = Rewriter::default(), value_parser = parse_rewriter, global = true, help_heading = CONFIGURATION_HELP_HEADING)]
142
    pub rewriter: Rewriter,
143

            
144
    /// Which strategy to use for expanding quantified variables in comprehensions.
145
    ///
146
    /// Possible values: `auto`, `native`, `via-solver`, `via-solver-ac`. `auto` chooses
147
    /// between native and solver-backed expansion from the comprehension's estimated size and
148
    /// available pruning constraints.
149
    #[arg(
150
        long,
151
        default_value_t = QuantifiedExpander::Auto,
152
        value_parser = parse_comprehension_expander,
153
        global = true,
154
        help_heading = MODELLING_HELP_HEADING
155
    )]
156
    pub comprehension_expander: QuantifiedExpander,
157

            
158
    /// Heuristic for selecting an answer when multiple modelling choices are applicable.
159
    ///
160
    /// Possible values: `f` (first), `r` (random), `c` (compact), `i` (interactive). Compact
161
    /// estimates structural work for supported Minion representation choices, falling back to
162
    /// representation-domain size elsewhere, and minimises resulting AST depth for equally-applicable
163
    /// rewrite rules. Use -v to inspect representation costs. Interactive prompts on stderr, or uses
164
    /// `--responses` when provided. `x` (all) is reserved for model generation and is not
165
    /// supported by the CLI yet.
166
    #[arg(
167
        long,
168
        short = 'h',
169
        default_value_t = Heuristic::Compact,
170
        value_parser = parse_cli_heuristic,
171
        global = true,
172
        help_heading = MODELLING_HELP_HEADING
173
    )]
174
    pub heuristic: Heuristic,
175

            
176
    /// Comma-separated 1-based answers for the interactive heuristic (`-h i`).
177
    ///
178
    /// If provided, these are used as the answers during interactive model generation instead of
179
    /// prompting the user.
180
    #[arg(
181
        long,
182
        value_name = "INTS",
183
        value_delimiter = ',',
184
        global = true,
185
        help_heading = MODELLING_HELP_HEADING
186
    )]
187
    pub responses: Vec<usize>,
188

            
189
    /// Seed used by the random heuristic.
190
    #[arg(
191
        long,
192
        default_value_t = DEFAULT_HEURISTIC_SEED,
193
        global = true,
194
        help_heading = MODELLING_HELP_HEADING
195
    )]
196
    pub seed: u64,
197

            
198
    /// Seed used by the backend solver's random search behaviour.
199
    #[arg(
200
        long,
201
        default_value_t = 0,
202
        global = true,
203
        help_heading = CONFIGURATION_HELP_HEADING
204
    )]
205
    pub solver_seed: u32,
206

            
207
    /// Whether multiple representations of the same declaration may be channelled together.
208
    ///
209
    /// Possible values: `no`, `yes`, `uniform`. Channelling is disabled by default.
210
    /// `uniform` uses one representation kind per type family throughout the model. Enable `yes` for
211
    /// different representations of the same variable at different call sites, e.g.
212
    /// `1 in (x :: set (representation packed) of int) /\ 2 in (x :: set (representation occurrence) of int)`.
213
    #[arg(
214
        long,
215
        default_value_t = Channelling::No,
216
        value_parser = parse_cli_channelling,
217
        global = true,
218
        help_heading = MODELLING_HELP_HEADING
219
    )]
220
    pub channelling: Channelling,
221

            
222
    /// Pin the SAT element composition: implication or support.
223
    #[arg(long = "sat-encoding-element", global = true, help_heading = MODELLING_HELP_HEADING)]
224
    pub element_encoding: Option<conjure_cp::ast::sat_decision::ElementEncoding>,
225

            
226
    /// Pin the SAT table composition: tuple, mdd or binary-support (constant two-column relations).
227
    #[arg(long = "sat-encoding-table", global = true, help_heading = MODELLING_HELP_HEADING)]
228
    pub table_encoding: Option<conjure_cp::ast::sat_decision::TableEncoding>,
229

            
230
    /// Pin allDifferent: pairwise, or value-amo (requires Direct or Boolean value indicators).
231
    #[arg(long = "sat-encoding-alldifferent", global = true, help_heading = MODELLING_HELP_HEADING)]
232
    pub alldifferent_encoding: Option<conjure_cp::ast::sat_decision::AllDifferentEncoding>,
233

            
234
    /// Pin the SAT AMO encoder: pairwise, ladder, bitwise, commander, bimander, two-product,
235
    /// pindakaas-pairwise, pindakaas-ladder or pindakaas-bitwise.
236
    /// If omitted, compact chooses per constraint; portfolio heuristics share one family choice.
237
    #[arg(long = "sat-encoding-amo", global = true, help_heading = MODELLING_HELP_HEADING)]
238
    pub amo_encoding: Option<conjure_cp::ast::sat_decision::AmoEncoding>,
239

            
240
    /// Pin the SAT cardinality encoder: rustsat-totalizer or pindakaas-sorting-network.
241
    #[arg(long = "sat-encoding-cardinality", global = true, help_heading = MODELLING_HELP_HEADING)]
242
    pub cardinality_encoding: Option<conjure_cp::ast::sat_decision::CardinalityEncoding>,
243

            
244
    /// Pin the SAT weighted encoder: rustsat-generalized-totalizer, rustsat-binary-adder, pindakaas-bdd, rustsat-dynamic-poly-watchdog, or pindakaas-swc.
245
    #[arg(long = "sat-encoding-pb", global = true, help_heading = MODELLING_HELP_HEADING)]
246
    pub pb_encoding: Option<conjure_cp::ast::sat_decision::PbEncoding>,
247

            
248
    /// Solver to use.
249
    ///
250
    /// Possible values: `minion`, `sat`, `z3`.
251
    ///
252
    /// How a model is expressed for the chosen solver -- which SAT encoding an integer gets, or
253
    /// which Z3 theory -- is a modelling choice made per declaration, not part of the solver name.
254
    /// Use `--heuristic` to steer those choices and `--channelling` to allow more than one per
255
    /// declaration.
256
    #[arg(
257
        long,
258
        value_name = "SOLVER",
259
        value_parser = parse_solver_family,
260
        default_value = "minion",
261
        short = 's',
262
        global = true,
263
        help_heading = CONFIGURATION_HELP_HEADING
264
    )]
265
    pub solver: SolverFamily,
266

            
267
    /// SAT backend to use with --solver sat (only compiled backends are available).
268
    #[arg(long, value_enum, default_value_t = SatBackend::default(), global = true,
269
        help_heading = CONFIGURATION_HELP_HEADING)]
270
    pub sat_backend: SatBackend,
271

            
272
    /// Pin the int-domain span threshold for using Minion `DISCRETE` variables.
273
    ///
274
    /// If maximum - minimum + 1 <= this value, emit `DISCRETE`; otherwise `BOUND`.
275
    /// Constraints requiring `DISCRETE` override this choice. If omitted, the heuristic chooses
276
    /// between 10, zero (all `BOUND`), and unlimited (all `DISCRETE`). Compact chooses 10.
277
    #[arg(
278
        long,
279
        global = true,
280
        help_heading = MODELLING_HELP_HEADING
281
    )]
282
    pub minion_discrete_threshold: Option<usize>,
283

            
284
    /// Override Minion variable ordering.
285
    ///
286
    /// Possible values: `static`, `sdf`, `srf`, `ldf`, `random`, `conflict`, `wdeg`,
287
    /// `domoverwdeg`.
288
    #[arg(
289
        long,
290
        value_name = "ORDER",
291
        value_parser = parse_minion_variable_order,
292
        global = true,
293
        help_heading = CONFIGURATION_HELP_HEADING
294
    )]
295
    pub minion_varorder: Option<MinionVariableOrder>,
296

            
297
    /// Override Minion value ordering.
298
    ///
299
    /// Possible values: `ascend`, `descend`, `random`.
300
    #[arg(
301
        long,
302
        value_name = "ORDER",
303
        value_parser = parse_minion_value_order,
304
        global = true,
305
        help_heading = CONFIGURATION_HELP_HEADING
306
    )]
307
    pub minion_valorder: Option<MinionValueOrder>,
308

            
309
    /// Save a solver input file to <filename>.
310
    ///
311
    /// This input file will be in a format compatible by the command-line
312
    /// interface of the selected solver. For example, when the solver is Minion,
313
    /// a valid .minion file will be output.
314
    ///
315
    /// This file is for informational purposes only; the results of running
316
    /// this file cannot be used by Conjure Oxide in any way.
317
    #[arg(long,global=true, value_names=["filename"], next_line_help=true, help_heading=LOGGING_HELP_HEADING)]
318
    pub save_solver_input_file: Option<PathBuf>,
319

            
320
    /// Stop the solver after the given cumulative wall-clock timeout.
321
    ///
322
    /// Minion has one-second timeout resolution, so finer durations are rounded up.
323
    #[arg(long, global = true, help_heading = CONFIGURATION_HELP_HEADING)]
324
    pub solver_timeout: Option<humantime::Duration>,
325

            
326
    /// Write general logs to this file
327
    #[arg(long, value_name = "PATH", global = true, help_heading = LOGGING_HELP_HEADING)]
328
    pub log_file: Option<PathBuf>,
329

            
330
    /// Format used by --log-file [default: text]
331
    #[arg(long, value_enum, requires = "log_file", global = true, help_heading = LOGGING_HELP_HEADING)]
332
    pub log_format: Option<LogFormat>,
333

            
334
    /// Detail written by --log-file [default: stages]
335
    #[arg(long, value_enum, requires = "log_file", global = true, help_heading = LOGGING_HELP_HEADING)]
336
    pub log_detail: Option<LogDetail>,
337
}
338

            
339
impl GlobalArgs {
340
    /// Convert command-line options into the library's modelling configuration.
341
322
    pub(crate) fn library_config(&self) -> conjure_cp::pipeline::Config {
342
        use conjure_cp::pipeline::{Config, TraceConfig};
343
322
        Config {
344
322
            parser: self.parser,
345
322
            rewriter: self.rewriter,
346
322
            comprehension_expander: self.comprehension_expander,
347
322
            solver: self.solver,
348
322
            extra_rule_sets: self.extra_rule_sets.clone(),
349
322
            heuristic: self.heuristic,
350
322
            seed: self.seed,
351
322
            responses: self.responses.clone(),
352
322
            channelling: self.channelling,
353
322
            amo_encoding: self.amo_encoding,
354
322
            cardinality_encoding: self.cardinality_encoding,
355
322
            pb_encoding: self.pb_encoding,
356
322
            element_encoding: self.element_encoding,
357
322
            table_encoding: self.table_encoding,
358
322
            alldifferent_encoding: self.alldifferent_encoding,
359
322
            minion_discrete_threshold: self.minion_discrete_threshold,
360
322
            minion_varorder: self.minion_varorder,
361
322
            minion_valorder: self.minion_valorder,
362
322
            sat_backend: self.sat_backend,
363
322
            solver_seed: self.solver_seed,
364
322
            solver_timeout: self.solver_timeout.map(std::time::Duration::from),
365
322
            trace: TraceConfig {
366
322
                rules: self.rule_trace.is_some(),
367
322
                attempts: self.rule_attempt_trace.is_some(),
368
322
                aggregates: self.rule_trace_aggregates.is_some(),
369
322
            },
370
322
        }
371
322
    }
372
}
373

            
374
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
375
pub enum LogFormat {
376
    #[default]
377
    Text,
378
    Json,
379
}
380

            
381
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
382
pub enum LogDetail {
383
    #[default]
384
    Stages,
385
    Applications,
386
    Attempts,
387
}
388

            
389
#[derive(Debug, Clone, Args)]
390
pub struct CompletionArgs {
391
    /// Shell type for which to generate the completion script
392
    #[arg(value_enum)]
393
    pub shell: Shell,
394
}
395

            
396
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
397
pub enum ShellTypes {
398
    Bash,
399
    Zsh,
400
    Fish,
401
    PowerShell,
402
    Elvish,
403
}
404

            
405
674
fn parse_comprehension_expander(input: &str) -> Result<QuantifiedExpander, String> {
406
674
    input.parse()
407
674
}
408

            
409
674
fn parse_cli_heuristic(input: &str) -> Result<Heuristic, String> {
410
674
    match input.parse::<Heuristic>()? {
411
        Heuristic::All => {
412
            Err("heuristic 'x' (all) is not supported by the command line yet".to_string())
413
        }
414
674
        heuristic => Ok(heuristic),
415
    }
416
674
}
417

            
418
674
fn parse_cli_channelling(input: &str) -> Result<Channelling, String> {
419
674
    input.parse::<Channelling>()
420
674
}
421

            
422
674
fn parse_rewriter(input: &str) -> Result<Rewriter, String> {
423
674
    input.parse::<Rewriter>()
424
674
}
425

            
426
674
fn parse_solver_family(input: &str) -> Result<SolverFamily, String> {
427
674
    let family = input.parse()?;
428
674
    if family == SolverFamily::Z3 && !cfg!(feature = "z3") {
429
        return Err("Z3 solver support was not compiled in (enable the `z3` feature).".into());
430
674
    }
431
674
    Ok(family)
432
674
}
433

            
434
674
fn parse_parser(input: &str) -> Result<InputParser, String> {
435
674
    input.parse()
436
674
}
437

            
438
fn parse_minion_value_order(input: &str) -> Result<MinionValueOrder, String> {
439
    match input {
440
        "ascend" => Ok(MinionValueOrder::Ascend),
441
        "descend" => Ok(MinionValueOrder::Descend),
442
        "random" => Ok(MinionValueOrder::Random),
443
        other => Err(format!(
444
            "unknown minion value order '{other}', expected one of: ascend, descend, random"
445
        )),
446
    }
447
}
448

            
449
8
fn parse_minion_variable_order(input: &str) -> Result<MinionVariableOrder, String> {
450
8
    match input {
451
1
        "static" => Ok(MinionVariableOrder::Static),
452
1
        "sdf" => Ok(MinionVariableOrder::SmallestDomainFirst),
453
1
        "srf" => Ok(MinionVariableOrder::SmallestRatioFirst),
454
1
        "ldf" => Ok(MinionVariableOrder::LargestDomainFirst),
455
1
        "random" => Ok(MinionVariableOrder::Random),
456
1
        "conflict" => Ok(MinionVariableOrder::Conflict),
457
1
        "wdeg" => Ok(MinionVariableOrder::WeightedDegree),
458
1
        "domoverwdeg" => Ok(MinionVariableOrder::DomainOverWeightedDegree),
459
        other => Err(format!(
460
            "unknown minion variable order '{other}', expected one of: static, sdf, srf, ldf, \
461
             random, conflict, wdeg, domoverwdeg"
462
        )),
463
    }
464
8
}
465

            
466
#[cfg(test)]
467
mod tests {
468
    use super::*;
469

            
470
    #[test]
471
1
    fn sat_backend_defaults_to_available_native_backend() {
472
        let cli =
473
1
            Cli::try_parse_from(["conjure-oxide", "solve", "model.essence", "--solver", "sat"])
474
1
                .unwrap();
475
        #[cfg(all(feature = "sat-cadical", not(target_family = "wasm")))]
476
1
        assert_eq!(cli.global_args.sat_backend, SatBackend::Cadical);
477
        #[cfg(not(all(feature = "sat-cadical", not(target_family = "wasm"))))]
478
        assert_eq!(cli.global_args.sat_backend, SatBackend::Batsat);
479
1
    }
480

            
481
    #[test]
482
1
    fn sat_backend_option_accepts_only_compiled_backends() {
483
1
        for name in ["cadical", "batsat"] {
484
2
            let result = Cli::try_parse_from([
485
2
                "conjure-oxide",
486
2
                "solve",
487
2
                "model.essence",
488
2
                "--solver",
489
2
                "sat",
490
2
                "--sat-backend",
491
2
                name,
492
2
            ]);
493
2
            let available = SatBackend::value_variants()
494
2
                .iter()
495
3
                .find(|backend| backend.to_string() == name);
496
2
            match available {
497
2
                Some(backend) => assert_eq!(result.unwrap().global_args.sat_backend, *backend),
498
                None => assert_eq!(
499
                    result.unwrap_err().kind(),
500
                    clap::error::ErrorKind::InvalidValue
501
                ),
502
            }
503
        }
504
1
    }
505

            
506
    #[cfg(not(feature = "z3"))]
507
    #[test]
508
    fn selecting_z3_without_support_reports_the_missing_feature() {
509
        let error =
510
            Cli::try_parse_from(["conjure-oxide", "solve", "model.essence", "--solver", "z3"])
511
                .unwrap_err();
512
        assert_eq!(error.kind(), clap::error::ErrorKind::ValueValidation);
513
        assert!(
514
            error
515
                .to_string()
516
                .contains("Z3 solver support was not compiled in")
517
        );
518
    }
519

            
520
    /// Regression test for #1631: `--version` used to fail as it requires a subcommand.
521
    #[test]
522
1
    fn version_flag_works_without_a_subcommand() {
523
1
        for flag in ["--version", "-V"] {
524
2
            let err = Cli::try_parse_from(["conjure-oxide", flag]).unwrap_err();
525
2
            assert_eq!(err.kind(), clap::error::ErrorKind::DisplayVersion);
526
2
            assert!(err.to_string().starts_with("conjure-oxide "));
527
        }
528
1
    }
529

            
530
    #[test]
531
1
    fn compact_is_the_default_cli_heuristic() {
532
1
        let cli = Cli::try_parse_from(["conjure-oxide", "solve", "model.essence"]).unwrap();
533
1
        assert_eq!(cli.global_args.heuristic, Heuristic::Compact);
534
1
    }
535

            
536
    #[test]
537
1
    fn auto_is_the_default_comprehension_expander() {
538
1
        let cli = Cli::try_parse_from(["conjure-oxide", "solve", "model.essence"]).unwrap();
539
1
        assert_eq!(
540
1
            cli.global_args.comprehension_expander,
541
1
            QuantifiedExpander::Auto
542
        );
543
1
    }
544

            
545
    #[test]
546
1
    fn solver_seed_defaults_to_zero_and_can_be_overridden() {
547
1
        let cli = Cli::try_parse_from(["conjure-oxide", "solve", "model.essence"]).unwrap();
548
1
        assert_eq!(cli.global_args.solver_seed, 0);
549

            
550
1
        let cli = Cli::try_parse_from([
551
1
            "conjure-oxide",
552
1
            "solve",
553
1
            "model.essence",
554
1
            "--solver-seed",
555
1
            "42",
556
1
        ])
557
1
        .unwrap();
558
1
        assert_eq!(cli.global_args.solver_seed, 42);
559
1
    }
560

            
561
    #[test]
562
1
    fn parses_all_minion_variable_orders() {
563
1
        let cases = [
564
1
            ("static", MinionVariableOrder::Static),
565
1
            ("sdf", MinionVariableOrder::SmallestDomainFirst),
566
1
            ("srf", MinionVariableOrder::SmallestRatioFirst),
567
1
            ("ldf", MinionVariableOrder::LargestDomainFirst),
568
1
            ("random", MinionVariableOrder::Random),
569
1
            ("conflict", MinionVariableOrder::Conflict),
570
1
            ("wdeg", MinionVariableOrder::WeightedDegree),
571
1
            ("domoverwdeg", MinionVariableOrder::DomainOverWeightedDegree),
572
1
        ];
573

            
574
1
        for (name, expected) in cases {
575
8
            let cli = Cli::try_parse_from([
576
8
                "conjure-oxide",
577
8
                "solve",
578
8
                "model.essence",
579
8
                "--minion-varorder",
580
8
                name,
581
8
            ])
582
8
            .unwrap();
583
8
            assert_eq!(cli.global_args.minion_varorder, Some(expected));
584
        }
585
1
    }
586
}