Repository: borgbackup/borg

Issue:
[1.2.0a6] borg compact doesn't use BORG_REPO env variable
I get this:
`borg-1.2.0a6 compact: error: the following arguments are required: REPOSITORY`

borg list, for example, works fine.


Discussion:
`nargs='?', default=''` missing - seems to affect more commands than just `compact`.

Also, the placeholders (like `REPO` or `REPO::ARCHIVE`) could be cleaned up.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -2821,7 +2821,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                             help='mount repository')
         subparser.set_defaults(func=self.do_mount)
         subparser.add_argument('location', metavar='REPOSITORY_OR_ARCHIVE', type=location_validator(),
-                            help='repository/archive to mount')
+                            help='repository or archive to mount')
         subparser.add_argument('mountpoint', metavar='MOUNTPOINT', type=str,
                             help='where to mount filesystem')
         subparser.add_argument('-f', '--foreground', dest='foreground',
@@ -3567,9 +3567,9 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                     'use ``--force --force`` in case ``--force`` does not work.')
         subparser.add_argument('--save-space', dest='save_space', action='store_true',
                                help='work slower, but using less space')
-        subparser.add_argument('location', metavar='TARGET', nargs='?', default='',
+        subparser.add_argument('location', metavar='REPOSITORY_OR_ARCHIVE', nargs='?', default='',
                                type=location_validator(),
-                               help='archive or repository to delete')
+                               help='repository or archive to delete')
         subparser.add_argument('archives', metavar='ARCHIVE', nargs='*',
                                help='archives to delete')
         define_archive_filters_group(subparser)
@@ -3618,7 +3618,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                     'A "bpath" key is therefore not available.')
         subparser.add_argument('location', metavar='REPOSITORY_OR_ARCHIVE', nargs='?', default='',
                                type=location_validator(),
-                               help='repository/archive to list contents of')
+                               help='repository or archive to list contents of')
         subparser.add_argument('paths', metavar='PATH', nargs='*', type=str,
                                help='paths to list; patterns are supported')
         define_archive_filters_group(subparser)
@@ -3664,7 +3664,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
         subparser.set_defaults(func=self.do_info)
         subparser.add_argument('location', metavar='REPOSITORY_OR_ARCHIVE', nargs='?', default='',
                                type=location_validator(),
-                               help='archive or repository to display information about')
+                               help='repository or archive to display information about')
         subparser.add_argument('--json', action='store_true',
                                help='format output as JSON')
         define_archive_filters_group(subparser)
@@ -3972,7 +3972,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
 
         subparser.add_argument('location', metavar='REPOSITORY_OR_ARCHIVE', nargs='?', default='',
                                type=location_validator(),
-                               help='repository/archive to recreate')
+                               help='repository or archive to recreate')
         subparser.add_argument('paths', metavar='PATH', nargs='*', type=str,
                                help='paths to recreate; patterns are supported')
 
@@ -4035,7 +4035,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
         group.add_argument('-l', '--list', dest='list', action='store_true',
                                help='list the configuration of the repo')
 
-        subparser.add_argument('location', metavar='REPOSITORY',
+        subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
                                type=location_validator(archive=False, proto='file'),
                                help='repository to configure')
         subparser.add_argument('name', metavar='NAME', nargs='?',
@@ -4134,7 +4134,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
         subparser.set_defaults(func=self.do_debug_dump_repo_objs)
         subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
-                               help='repo to dump')
+                               help='repository to dump')
         subparser.add_argument('--ghost', dest='ghost', action='store_true',
                                help='dump all segment file contents, including deleted/uncommitted objects and commits.')
 
@@ -4149,7 +4149,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
         subparser.set_defaults(func=self.do_debug_search_repo_objs)
         subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
-                               help='repo to search')
+                               help='repository to search')
         subparser.add_argument('wanted', metavar='WANTED', type=str,
                                help='term to search the repo for, either 0x1234abcd hex term or a string')
 
@@ -4162,7 +4162,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                           formatter_class=argparse.RawDescriptionHelpFormatter,
                                           help='get object from repository (debug)')
         subparser.set_defaults(func=self.do_debug_get_obj)
-        subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
+        subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
                                help='repository to use')
         subparser.add_argument('id', metavar='ID', type=str,
@@ -4179,7 +4179,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                           formatter_class=argparse.RawDescriptionHelpFormatter,
                                           help='put object to repository (debug)')
         subparser.set_defaults(func=self.do_debug_put_obj)
-        subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
+        subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
                                help='repository to use')
         subparser.add_argument('paths', metavar='PATH', nargs='+', type=str,
@@ -4194,7 +4194,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                           formatter_class=argparse.RawDescriptionHelpFormatter,
                                           help='delete object from repository (debug)')
         subparser.set_defaults(func=self.do_debug_delete_obj)
-        subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
+        subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
                                help='repository to use')
         subparser.add_argument('ids', metavar='IDs', nargs='+', type=str,
@@ -4209,7 +4209,7 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                           formatter_class=argparse.RawDescriptionHelpFormatter,
                                           help='show refcount for object from repository (debug)')
         subparser.set_defaults(func=self.do_debug_refcount_obj)
-        subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
+        subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
                                help='repository to use')
         subparser.add_argument('ids', metavar='IDs', nargs='+', type=str,
@@ -4286,9 +4286,9 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                                  help='benchmarks borg CRUD (create, extract, update, delete).')
         subparser.set_defaults(func=self.do_benchmark_crud)
 
-        subparser.add_argument('location', metavar='REPO',
+        subparser.add_argument('location', metavar='REPOSITORY',
                                type=location_validator(archive=False),
-                               help='repo to use for benchmark (must exist)')
+                               help='repository to use for benchmark (must exist)')
 
         subparser.add_argument('path', metavar='PATH', help='path were to create benchmark input data')
 


Test patch: