Skip to content

Add --dry-run flag to parler cleanup #11

Description

@AbdelStark

Summary

Add a --dry-run flag to parler cleanup that shows what would be deleted without actually removing anything. This is a safe, confidence-building option for operators running cleanup in production environments.

Background

parler cleanup currently prunes stale run bundles and temp audio files immediately when invoked. There is no way to preview what will be removed before committing. A --dry-run mode is a standard UX pattern for any destructive CLI command and makes the tool easier to trust.

What to implement

Add a --dry-run flag to the cleanup command in parler/cli.py:

# Preview only — prints what would be removed, removes nothing
parler cleanup --dry-run --older-than-days 7

# Current behaviour unchanged
parler cleanup --older-than-days 7

Expected dry-run output (text mode):

[dry-run] Would remove 3 run bundle(s) and 1 temp audio file(s) older than 7.0 day(s).

Expected dry-run output (--json mode):

{
  "dry_run": true,
  "older_than_days": 7.0,
  "would_remove_runs": 3,
  "would_remove_temp_audio": 1
}

When --dry-run is set, the function should call the existing prune_* helpers with a counting approach but skip deletion — or add a dry_run=True parameter to prune_run_summaries and prune_managed_audio_files in parler/runlog.py and parler/audio/ingester.py.

Files to look at

File What to understand
parler/cli.pycleanup command (~line 956) Where to add the --dry-run option and conditional logic
parler/runlog.pyprune_run_summaries() The existing prune logic to make dry-run-aware
parler/audio/ingester.pyprune_managed_audio_files() Same, for temp audio
tests/unit/test_cli_commands.pyTestOperationalCommands Where to add tests

Acceptance criteria

  • parler cleanup --dry-run prints what would be removed and exits 0
  • Nothing is deleted when --dry-run is set
  • --dry-run composes correctly with --older-than-days, --runs, --no-runs, --temp-audio, --no-temp-audio
  • --dry-run --json emits a JSON object with a "dry_run": true key alongside the counts
  • At least two unit tests covering dry-run behaviour (one text, one JSON)
  • ruff check and ruff format --check pass

Setting up

git clone https://github.com/AbdelStark/mistral-parler && cd mistral-parler
uv sync --locked --group dev
uv run parler doctor          # verify environment
uv run pytest tests/unit/test_cli_commands.py -q   # confirm baseline

Tips for first-timers

  • All CLI commands use Click. Adding a boolean flag is a one-liner: @click.option("--dry-run", is_flag=True, help="...")
  • The cleanup command already receives runs: bool and temp_audio: bool flags — pattern your dry-run logic similarly
  • Use CliRunner from click.testing for tests (see existing test_runs_list_show_and_cleanup for a reference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:uxCLI, TUI, review workflow, or usability improvementsenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions