fix: replace inverted -r flag with -n/--no-recursive
This commit is contained in:
parent
be71728e1a
commit
81d9d62db3
3 changed files with 20 additions and 2 deletions
|
|
@ -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 |
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue