mirror of
https://github.com/borgbackup/borg.git
synced 2026-05-22 18:16:02 -04:00
Merge 80b967ea56 into e2a651c684
This commit is contained in:
commit
0a1ed6a4e2
2 changed files with 20 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ from ._common import with_repository, build_matcher, Highlander
|
|||
from ..archive import Archive
|
||||
from ..cache import Cache
|
||||
from ..constants import * # NOQA
|
||||
from ..helpers import ItemFormatter, BaseFormatter, archivename_validator, PathSpec
|
||||
from ..helpers import ItemFormatter, BaseFormatter, archivename_validator, PathSpec, set_ec
|
||||
from ..helpers.argparsing import ArgumentParser
|
||||
from ..manifest import Manifest
|
||||
|
||||
|
|
@ -19,6 +19,14 @@ class ListMixIn:
|
|||
@with_repository(compatibility=(Manifest.Operation.READ,))
|
||||
def do_list(self, args, repository, manifest):
|
||||
"""List archive contents."""
|
||||
if args.name is None:
|
||||
print(
|
||||
"Error: borg list requires an archive NAME.\n"
|
||||
"To list the archives in a repository, use: borg repo-list",
|
||||
file=sys.stderr,
|
||||
)
|
||||
set_ec(EXIT_ERROR)
|
||||
return
|
||||
# omitting args.pattern_roots here, restricting to paths only by cli args.paths:
|
||||
matcher = build_matcher(args.patterns, args.paths)
|
||||
if args.format is not None:
|
||||
|
|
@ -126,7 +134,9 @@ class ListMixIn:
|
|||
subparser.add_argument(
|
||||
"--depth", metavar="N", dest="depth", type=int, help="only list files up to the specified directory depth"
|
||||
)
|
||||
subparser.add_argument("name", metavar="NAME", type=archivename_validator, help="specify the archive name")
|
||||
subparser.add_argument(
|
||||
"name", metavar="NAME", nargs="?", default=None, type=archivename_validator, help="specify the archive name"
|
||||
)
|
||||
subparser.add_argument(
|
||||
"paths", metavar="PATH", nargs="*", type=PathSpec, help="paths to list; patterns are supported"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -259,3 +259,11 @@ def test_fingerprint(archivers, request):
|
|||
|
||||
# Even unmodified files should have different fingerprints because conditions_hash changed
|
||||
assert fingerprints1["input/file2"] != fingerprints5["input/file2"]
|
||||
|
||||
|
||||
def test_list_without_archive_name_shows_helpful_error(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "list", exit_code=2)
|
||||
assert "borg list requires an archive NAME" in output
|
||||
assert "borg repo-list" in output
|
||||
|
|
|
|||
Loading…
Reference in a new issue