浏览代码

Don't auto-add CLI flags for configuration options that already have per-action CLI flags (#303).

Dan Helfman 3 月之前
父节点
当前提交
7d989f727d
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 8 0
      borgmatic/commands/arguments.py
  2. 6 3
      borgmatic/config/schema.yaml

+ 8 - 0
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('_', '-')}"
 

+ 6 - 3
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: