From 38a47ab7937fad7953b42e6ef46b320b1b37b1d6 Mon Sep 17 00:00:00 2001 From: tech Date: Wed, 22 Apr 2026 12:05:25 +0800 Subject: [PATCH] refactor: remove --csv arg from delete, auto-pick latest backup Co-Authored-By: Claude Sonnet 4.6 --- src/order_bak/cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/order_bak/cli.py b/src/order_bak/cli.py index c307a22..73ee1bf 100644 --- a/src/order_bak/cli.py +++ b/src/order_bak/cli.py @@ -63,14 +63,18 @@ def backup(ctx, days, scan_path): @main.command() -@click.option("--csv", "csv_path", required=True, type=click.Path(exists=True), help="Path to backup CSV to delete") @click.pass_context -def delete(ctx, csv_path): +def delete(ctx): cfg = load_config(ctx.obj["config_path"]) from azure.data.tables import TableClient from order_bak.delete import delete_orders - csv_file = Path(csv_path) + backup_dir = Path("./backups") + backup_files = sorted(backup_dir.glob("*.csv")) + if not backup_files: + click.echo("No backup files found in ./backups") + raise SystemExit(1) + csv_file = backup_files[-1] import csv as csv_mod with open(csv_file, newline="") as f: