Repository: psss/did

Issue:
Warn when since/until options are used with relative time
We should clearly warn when user (e.g. by a copy & paste accident)
specifies `--since` or `--until` options together with relative
time specification such as `last week` as it's not clear what the
desired result should be. Refusing to guess and suggesting to the
user to choose seems to be the most straightforward solution.

Discussion:

Solution patch:
diff --git a/did/cli.py b/did/cli.py
index 00dda2a..f78d15c 100644
--- a/did/cli.py
+++ b/did/cli.py
@@ -136,6 +136,10 @@ class Options():
         if opt.since is None and opt.until is None:
             opt.since, opt.until, period = did.base.Date.period(arg)
         else:
+            if self.arg:
+                raise did.base.OptionError(
+                    f'Can\'t use --since or --until with \'{" ".join(self.arg)}\''
+                    )
             opt.since = did.base.Date(opt.since or "1993-01-01")
             opt.until = did.base.Date(opt.until or "today")
             # Make the 'until' limit inclusive


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 5939360..80c19f6 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -63,3 +63,11 @@ def test_invalid_date():
     for argument in ["--since x", "--since 2015-16-17"]:
         with pytest.raises(did.base.OptionError):
             did.cli.main(argument)
+
+
+def test_conflicting_options():
+    """ Complain about conflicting options """
+    did.base.Config(config=MINIMAL)
+    for argument in ["last week --since 2025-05-29", "last week --until 2025-05-29"]:
+        with pytest.raises(did.base.OptionError):
+            did.cli.main(argument)