From 81d9d62db37fd268a7d9c0ed043e91b1728ac63a Mon Sep 17 00:00:00 2001 From: randogoth Date: Sat, 24 Oct 2026 21:23:23 +0300 Subject: [PATCH] fix: replace inverted -r flag with -n/--no-recursive --- README.md | 2 +- orvanitag/cmd.py | 2 +- tests/test_plugins.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d66a56b..aa44a27 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ A term with a prefix only matches that category; a term without a prefix matches | `--files` | Only show files | | `-d`, `--dirs` | Only show folders | | `-p`, `--path PATH` | Search another directory tree | -| `-r`, `--recursive` | Skip subdirectories (despite its name; subdirectories are included by default) | +| `-n`, `--no-recursive` | Skip subdirectories (also for `clean` and `scan`) | | `-c`, `--cache` | Read the index from `.otag.cache.json`, which is rebuilt whenever an `.otag` file changed | | `-dc`, `--delete-cache` | Delete `.otag.cache.json` before searching | diff --git a/orvanitag/cmd.py b/orvanitag/cmd.py index 8811de3..14a4e89 100644 --- a/orvanitag/cmd.py +++ b/orvanitag/cmd.py @@ -115,7 +115,7 @@ def main(): """ # Command Line Argument Setup p = argp(description="OrvaniTagger (otag)", formatter_class=raw) - p.add_argument("--recursive", "-r", action="store_false", help="(list,clean,purge,export) Include subdirectories in search") + p.add_argument("--no-recursive", "-n", dest="recursive", action="store_false", help="(list,clean,scan) Skip subdirectories") p.add_argument("--file-operation", "-f", action="store_true", help="(copy,move,del) Do file operation, not just context") p.add_argument("--path", "-p", action="store", type=str, help="(list,export) Use custom path", default='') p.add_argument("--exact", "-e", action="store_true", help="(list) Match exact search term") diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 1320bd1..0a5d501 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -102,3 +102,21 @@ def test_cmd_prints_errors(cwd, monkeypatch, capsys): main() assert exit.value.code == 1 assert '.otag:1' in capsys.readouterr().out + + +def test_cmd_list_is_recursive_unless_no_recursive(cwd, monkeypatch, capsys): + (cwd / 'a.mp3').touch() + (cwd / 'sub').mkdir() + (cwd / 'sub' / 'deep.mp3').touch() + OrvaniTag().add('a.mp3', '#lofi') + OrvaniTag().add('sub/deep.mp3', '#lofi') + + monkeypatch.setattr(sys, 'argv', ['otag', 'ls', '#lofi']) + main() + out = capsys.readouterr().out + assert 'a.mp3' in out and 'deep.mp3' in out + + monkeypatch.setattr(sys, 'argv', ['otag', 'ls', '-n', '#lofi']) + main() + out = capsys.readouterr().out + assert 'a.mp3' in out and 'deep.mp3' not in out