bin: handle '--parity=X --colored-parity' like '--colored-parity=X'

Fixes #602.

* bin/common_post.cc (-P, -p): Do not overwrite an existing parity
specification if none were given.
* tests/core/parity2.test: Test this.
This commit is contained in:
Alexandre Duret-Lutz 2025-03-11 10:14:46 +01:00
parent 1dd2ce3ae2
commit b6e782589e
2 changed files with 73 additions and 2 deletions

View file

@ -231,7 +231,14 @@ parse_opt_post(int key, char* arg, struct argp_state*)
if (arg)
type = XARGMATCH(key == 'P' ? "--parity" : "--colored-parity",
arg, parity_args, parity_types);
else
else if (!(type & spot::postprocessor::Parity))
// If no argument was given, we just require Parity.
// However, if a Parity condition was already set before,
// don't overwrite it. This way if someone mistakenly write
// `--parity='max even' --colored` without realizing that
// `--colored` is just the abbreviation for
// `--colored-parity=...` with the default argument, we
// won't reset the 'max even' setting.
type = spot::postprocessor::Parity;
if (key == 'p')
colored = spot::postprocessor::Colored;