瀏覽代碼

delete: more Highlander options, fixes #6269

Thomas Waldmann 2 年之前
父節點
當前提交
13e99033cb
共有 2 個文件被更改,包括 15 次插入7 次删除
  1. 13 6
      src/borg/archiver/_common.py
  2. 2 1
      src/borg/archiver/delete_cmd.py

+ 13 - 6
src/borg/archiver/_common.py

@@ -372,6 +372,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True, ol
             dest="sort_by",
             type=SortBySpec,
             default=sort_by_default,
+            action=Highlander,
             help="Comma-separated list of sorting keys; valid keys are: {}; default is: {}".format(
                 ", ".join(AI_HUMAN_SORT_KEYS), sort_by_default
             ),
@@ -383,16 +384,18 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True, ol
             "--first",
             metavar="N",
             dest="first",
-            default=0,
             type=positive_int_validator,
+            default=0,
+            action=Highlander,
             help="consider first N archives after other filters were applied",
         )
         group.add_argument(
             "--last",
             metavar="N",
             dest="last",
-            default=0,
             type=positive_int_validator,
+            default=0,
+            action=Highlander,
             help="consider last N archives after other filters were applied",
         )
 
@@ -401,15 +404,17 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True, ol
         group.add_argument(
             "--oldest",
             metavar="TIMESPAN",
-            type=relative_time_marker_validator,
             dest="oldest",
+            type=relative_time_marker_validator,
+            action=Highlander,
             help="consider archives between the oldest archive's timestamp and (oldest + TIMESPAN), e.g. 7d or 12m.",
         )
         group.add_argument(
             "--newest",
             metavar="TIMESPAN",
-            type=relative_time_marker_validator,
             dest="newest",
+            type=relative_time_marker_validator,
+            action=Highlander,
             help="consider archives between the newest archive's timestamp and (newest - TIMESPAN), e.g. 7d or 12m.",
         )
 
@@ -418,15 +423,17 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True, ol
         group.add_argument(
             "--older",
             metavar="TIMESPAN",
-            type=relative_time_marker_validator,
             dest="older",
+            type=relative_time_marker_validator,
+            action=Highlander,
             help="consider archives older than (now - TIMESPAN), e.g. 7d oder 12m.",
         )
         group.add_argument(
             "--newer",
             metavar="TIMESPAN",
-            type=relative_time_marker_validator,
             dest="newer",
+            type=relative_time_marker_validator,
+            action=Highlander,
             help="consider archives newer than (now - TIMESPAN), e.g. 7d or 12m.",
         )
 

+ 2 - 1
src/borg/archiver/delete_cmd.py

@@ -1,7 +1,7 @@
 import argparse
 import logging
 
-from ._common import with_repository
+from ._common import with_repository, Highlander
 from ..archive import Archive, Statistics
 from ..cache import Cache
 from ..constants import *  # NOQA
@@ -156,6 +156,7 @@ class DeleteMixIn:
             dest="checkpoint_interval",
             type=int,
             default=1800,
+            action=Highlander,
             help="write checkpoint every SECONDS seconds (Default: 1800)",
         )
         define_archive_filters_group(subparser)