diff --git a/README.md b/README.md index 8e02d68..42dad74 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ Create a YAML config file (see [`config.yaml`](config.yaml) for a template): paths: - /path/to/data -# Unix group whose members' subdirectories should be reported (optional) -group: your_group_name +# Unix groups whose members' subdirectories should be reported (optional) +groups: + - your_group_name # Shell-style glob patterns for files/directories to exclude (optional) ignore: @@ -37,7 +38,7 @@ ignore: | Key | Description | |---|---| | `paths` | List of top-level paths to scan (required) | -| `group` | Unix group name; enables group mode (optional, overridden by `--group`) | +| `groups` | List of Unix group names; enables group mode (optional, overridden by `--groups`) | | `ignore` | Glob patterns matched against base names to exclude from all scans | ## Usage @@ -49,7 +50,7 @@ python3 ontrack.py --config config.yaml [OPTIONS] | Option | Description | |---|---| | `--config FILE` | Path to the YAML config file (default: `config.yaml`) | -| `--group GROUP` | Unix group name; overrides the `group` key in the config file | +| `--groups GROUP [GROUP ...]` | One or more Unix group names; overrides the `groups` key in the config file | | `--light` | Skip file-count and size scanning; only report directory and owner | | `--progress` | Show progress bars while scanning | | `--output FILE` | Write the report as YAML to `FILE` instead of printing to stdout | @@ -62,10 +63,10 @@ python3 ontrack.py --config config.yaml [OPTIONS] python3 ontrack.py --config config.yaml ``` -**Group mode** — for each configured directory, finds and reports subdirectories owned by members of the specified Unix group. Descends until a directory containing at least one file is found: +**Group mode** — for each configured directory, finds and reports subdirectories owned by members of the specified Unix groups. Descends until a directory containing at least one file is found: ```bash -python3 ontrack.py --config config.yaml --group researchers +python3 ontrack.py --config config.yaml --groups researchers ``` ## Example Output diff --git a/ontrack.py b/ontrack.py index b07c212..ee7686b 100644 --- a/ontrack.py +++ b/ontrack.py @@ -346,7 +346,7 @@ def report_directory( print(f"Directory : {entry['directory']}") print(f"Username : {entry['username']}") if "groups" in entry: - print(f"Groups : {', '.join(entry['groups'])}") + print(f"Group : {', '.join(entry['groups'])}") if "file_count" in entry: print(f"Files : {entry['file_count']}") print(f"Total size: {entry['total_size_human']}") diff --git a/tests/test_ontrack.py b/tests/test_ontrack.py index 29c0b78..9c9767d 100644 --- a/tests/test_ontrack.py +++ b/tests/test_ontrack.py @@ -278,7 +278,7 @@ def test_get_directory_stats_group_excludes_files(): def test_report_directory_with_group(capsys): - """report_directory prints the Groups line when groups are supplied.""" + """report_directory prints the Group line when groups are supplied.""" current_gid = os.getgid() group_name = grp.getgrgid(current_gid).gr_name @@ -288,19 +288,17 @@ def test_report_directory_with_group(capsys): report_directory(tmpdir, groups=[group_name]) captured = capsys.readouterr() - assert "Groups" in captured.out + assert "Group" in captured.out assert group_name in captured.out - - def test_report_directory_without_group_no_group_line(capsys): - """report_directory does not print a Groups line when no groups are given.""" + """report_directory does not print a Group line when no groups are given.""" with tempfile.TemporaryDirectory() as tmpdir: with open(os.path.join(tmpdir, "sample.txt"), "w") as f: f.write("data") report_directory(tmpdir) captured = capsys.readouterr() - assert "Groups" not in captured.out + assert "Group :" not in captured.out # --------------------------------------------------------------------------- @@ -326,7 +324,7 @@ def test_main_with_group(tmp_path, capsys): main(str(config_file), groups=[group_name]) captured = capsys.readouterr() assert str(user_subdir) in captured.out - assert "Groups" in captured.out + assert "Group" in captured.out assert group_name in captured.out @@ -356,7 +354,7 @@ def test_main_with_multiple_groups(tmp_path, capsys): main(str(config_file), groups=[group_name, second_group]) captured = capsys.readouterr() assert str(user_subdir) in captured.out - assert "Groups" in captured.out + assert "Group" in captured.out assert group_name in captured.out