From 7d989f727dbb9a218cb548ecce236133f74a814b Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 20 Mar 2025 12:23:00 -0700 Subject: [PATCH] Don't auto-add CLI flags for configuration options that already have per-action CLI flags (#303). --- borgmatic/commands/arguments.py | 8 ++++++++ borgmatic/config/schema.yaml | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/borgmatic/commands/arguments.py b/borgmatic/commands/arguments.py index 5d980a72..dc72535f 100644 --- a/borgmatic/commands/arguments.py +++ b/borgmatic/commands/arguments.py @@ -288,6 +288,9 @@ def parse_arguments_for_actions(unparsed_arguments, action_parsers, global_parse ) +OMITTED_FLAG_NAMES = {'progress', 'stats', 'list'} + + def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names=None): ''' Given an argparse._ArgumentGroup instance, a configuration schema dict, and a sequence of @@ -376,6 +379,11 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names description = description.replace('%', '%%') + # These options already have corresponding flags on individual actions (like "create + # --progress"), so don't bother adding them to the global flags. + if flag_name in OMITTED_FLAG_NAMES: + return + argument_type = borgmatic.config.schema.parse_type(schema_type) full_flag_name = f"--{flag_name.replace('_', '-')}" diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 006b9436..86cc5255 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -813,21 +813,24 @@ properties: type: boolean description: | Display progress as each file or archive is processed when running - supported actions. Defaults to false. + supported actions. Corresponds to the "--progress" flag on those + actions. Defaults to false. default: false example: true stats: type: boolean description: | Display statistics for an archive when running supported actions. - Defaults to false. + Corresponds to the "--stats" flag on those actions. Defaults to + false. default: false example: true list: type: boolean description: | Display details for each file or archive as it is processed when - running supported actions. Defaults to false. + running supported actions. Corresponds to the "--list" flag on those + actions. Defaults to false. default: false example: true skip_actions: