Skip to content

Commit

Permalink
added ability to apply the info command to a particular archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Oct 30, 2022
1 parent 33e6222 commit 9453c38
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 2 additions & 0 deletions doc/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Latest development release
| Version: 1.33.1
| Released: 2022-10-30
- Added ability to apply the :ref:`info <info>` command to a particular archive.


1.33 (2022-10-22)
-----------------
Expand Down
34 changes: 18 additions & 16 deletions emborg/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ class InfoCommand(Command):
USAGE = dedent(
"""
Usage:
emborg info [options]
emborg info [options] [<archive>]
Options:
-f, --fast only report local information
Expand All @@ -1238,6 +1238,7 @@ def run(cls, command, args, settings, options):
# read command line
cmdline = docopt(cls.USAGE, argv=[command] + args)
fast = cmdline["--fast"]
archive = cmdline["<archive>"]

# run borg_options('create') to populate settings.roots
try:
Expand All @@ -1247,25 +1248,26 @@ def run(cls, command, args, settings, options):
roots = ['not set']

# report local information
output(f" config: {settings.config_name}")
output(f' roots: {", ".join(roots)}')
output(f" destination: {settings.destination()}")
output(f" settings directory: {settings.config_dir}")
output(f" logfile: {settings.logfile}")
try:
backup_date = arrow.get(settings.date_file.read_text())
output(f" last backed up: {backup_date}, {backup_date.humanize()}")
except FileNotFoundError as e:
narrate(os_error(e))
except arrow.parser.ParserError as e:
narrate(e, culprit=settings.date_file)
if fast:
return
if not archive:
output(f" config: {settings.config_name}")
output(f' roots: {", ".join(roots)}')
output(f" destination: {settings.destination()}")
output(f" settings directory: {settings.config_dir}")
output(f" logfile: {settings.logfile}")
try:
backup_date = arrow.get(settings.date_file.read_text())
output(f" last backed up: {backup_date}, {backup_date.humanize()}")
except FileNotFoundError as e:
narrate(os_error(e))
except arrow.parser.ParserError as e:
narrate(e, culprit=settings.date_file)
if fast:
return

# now output the information from borg about the repository
borg = settings.run_borg(
cmd = "info",
args = [settings.destination()],
args = [settings.destination(archive)],
emborg_opts = options,
strip_prefix = True,
)
Expand Down
10 changes: 5 additions & 5 deletions emborg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,6 @@ def run_borg(
)

# run the command
narrate(
"running:\n{}".format(
indent(render_command(command, borg_options_arg_count))
)
)
with cd(self.working_dir if use_working_dir else "."):
narrate("running in:", cwd())
if "--json" in command or "--json-lines" in command:
Expand All @@ -726,6 +721,11 @@ def run_borg(
display("\nRunning Borg {} command ...".format(cmd))
else:
modes = "sOEW1"
narrate(
"running:\n{}".format(
indent(render_command(command, borg_options_arg_count))
)
)
starts_at = arrow.now()
log("starts at: {!s}".format(starts_at))
try:
Expand Down
6 changes: 5 additions & 1 deletion tests/test-cases.nt
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,11 @@ emborg with configs:
unbalance:
args: --quiet --config test5 create
expected:
> Creating archive at (?s:.*)
> (?s:.*)
> .* repository check, no problems found.
> (?s:.*)
> Archive consistency check complete, no problems found.
> (?s:.*)
expected_type: regex

lobby:
Expand Down

0 comments on commit 9453c38

Please sign in to comment.