From 13e99033cb64b79ce167b4e3b3061986f031d263 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 6 Apr 2023 17:15:09 +0200 Subject: [PATCH] delete: more Highlander options, fixes #6269 --- src/borg/archiver/_common.py | 19 +++++++++++++------ src/borg/archiver/delete_cmd.py | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/borg/archiver/_common.py b/src/borg/archiver/_common.py index bbaaae526..9236d0d7f 100644 --- a/src/borg/archiver/_common.py +++ b/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.", ) diff --git a/src/borg/archiver/delete_cmd.py b/src/borg/archiver/delete_cmd.py index 5ff6817d4..e9444dcf7 100644 --- a/src/borg/archiver/delete_cmd.py +++ b/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 @@ def build_parser_delete(self, subparsers, common_parser, mid_common_parser): dest="checkpoint_interval", type=int, default=1800, + action=Highlander, help="write checkpoint every SECONDS seconds (Default: 1800)", ) define_archive_filters_group(subparser)